Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Lowest and Highest value in a row output

New Here ,
Jun 16, 2010 Jun 16, 2010

I have a number of product records returned with prices in a row like the following:

Product ID | Product Name | Price 1 | Price 2 | Price 3 | Price 4 |
        1                   Test             1.00       2.49       5.29       1.29
------------------------------------------------------------------------------------

        2                   Test  2         4.00       3.49       2.29       7.29

I need to highlight the lowest and the highest price in each row.
Any help would be greatly appreciated.
Cheers

949
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 16, 2010 Jun 16, 2010

Hello

You can use the  arrayMin, arrayMax functions in coldfusion

refer to

http://www.adobe.com/livedocs/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Co...

Thanks

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 16, 2010 Jun 16, 2010

Array functions work on columns, not rows.  I can think of a few ways to do what the OP is asking, but they are all convoluted.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 16, 2010 Jun 16, 2010

Thanks for all your help on this and have tried with arraymin and arraymax however some prices are 0.00 like the following:

Product ID | Product Name | Price 1 | Price 2 | Price 3 | Price 4 |
        1                   Test             1.00       0.00       0.00       1.29
-------------------------------------------------------------------------------- ----

        2                   Test  2         0.00       3.49       0.00       7.29

So somehow I need to bypass those 0.00 because arraymin returns the 0.00 as the lowest which ok it is, but i need to exclude those so in this example:

Product ID | Product Name | Price 1 | Price 2 | Price 3 | Price 4 |
        1                   Test             1.00       0.00       0.00       1.29

Price 2 and 3 should not be included and Price 1 is lowest price 2 is highest.

Please help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 18, 2010 Jun 18, 2010

The requirement to skip the zeroes makes me suspect you're confusing zero with null, and that will make a difference to how to approach this. What's the data coming from, an array or a query?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2010 Jun 18, 2010

Thank you very much, I've solved this now, please see below.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2010 Jun 18, 2010
LATEST

Thank you for all your help, this is what i needed to do to remove those array values which has a 0 in it, then I can find the lowest and highest:

<cfloop condition="arrayFind( PriceArray, '0' )">

<cfset arrayDelete( PriceArray, "0" ) />

</cfloop>
 
<cfset arrayDelete(PriceArray, "0" ) />


<cfset LowestPrice = ArrayMin(PriceArray)>
<cfset HighestPrice = ArrayMax(PriceArray)>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources