Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Hello
You can use the arrayMin, arrayMax functions in coldfusion
refer to
Thanks
Dan
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Thank you very much, I've solved this now, please see below.
Copy link to clipboard
Copied
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)>