Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nested Max Statements

I am trying to get a unit price for a particular PO# based on a selected date. I need to get the current unit price and compare it to the last unit price recorded, which could be different dates for each PO#. This last part is the one I am having problems with.

I am not having a problem grabbing the last date that the PO# has a unit price. I am using the following formula to find that date:

=Max({<PODate = {'>=$(=addmonths(PODate,-12)) <=$(=max(PODate))'} >} PODate,2)

This works great and tells me the last instance of the date based on my current date selection for each PO#. Now I just need to grab the unit price at those dates. For instance, below if I select 8/1/09, I want to grab the unti price for 7/1/09 for PO# 1 of 15.50, and the unit price of 7/2/09 for PO# 2 of 10.50, etc.

PO#SiteDateUnit Price
1south8/1/200920.50
1east7/1/200915.50
1west6/1/200910.50
2south8/1/20099.00
2west7/2/200910.50
2west6/1/200910.50
3west8/1/20099.00
3west6/1/200925.00
4north7/3/200930.00
4east6/1/200918.00


I can get it to provide the dates using the max function above, but when I try to get the unit price, I am having trouble. My thought was to nest the first formula into another set analysis (in bold below) where I would set the PODate equal to the date evaluated from above. When I use the below, the nested max statement only gives me one date and not the individual dates from the original formula.

=Max( {< PODate = {'=$(=Max({<PODate = {">=$(=addmonths(PODate,-12)) <=$(=max(PODate))"} >} PODate,2))'}>} unit_price)

Not sure if that has to do with the double quotes I used?? It won't evaluate anything if I use anything other than the double quotes for the nested set analysis.

Maybe I am looking at this the wrong way or using the wrong function for the second part?



0 Replies