Skip to main content
Known Participant
June 16, 2010
Question

Lowest and Highest value in a row output

  • June 16, 2010
  • 3 replies
  • 1004 views

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

    This topic has been closed for replies.

    3 replies

    AkosFAuthor
    Known Participant
    June 18, 2010

    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)>

    AkosFAuthor
    Known Participant
    June 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.

    Known Participant
    June 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?

    AkosFAuthor
    Known Participant
    June 18, 2010

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

    Participating Frequently
    June 16, 2010
    Inspiring
    June 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.