Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
QlikAngel
Partner - Creator
Partner - Creator

Max Vs Sequential Previous Data

Hi,

Please find the attached Sample Data & Output .

I want Org & Itemwise - Max Date of Purchased Price & sequentially Previous Purchase Price for the same Item & Org.

I am getting Max Purchased Price but Previous Purchase price not getting correct.

Please help

Regards,
Mayuri

19 Replies
tresesco
MVP
MVP

One Max row in your data -

N21XYZ2/3/16 12:00500

but you expect 300 as max price, how?

QlikAngel
Partner - Creator
Partner - Creator
Author

OutPut will be below

    

OrgItemCodeMax DatePrevious DateMax PricePrevious Price
N21XYZ2/3/2016 12:001/3/2016  17:00:00 PM500100
F24ABC1/3/2016  17:00:00 PM1/3/2016 10:00200100
F24XYZ2/3/2016 12:00-200-
QlikAngel
Partner - Creator
Partner - Creator
Author

you correct.. i have given correct output

QlikAngel
Partner - Creator
Partner - Creator
Author

Amit Biswas i am not able to see your reply..

tresesco
MVP
MVP

Straight table:

Dim1: Org

Dim2: ItemCode

Max Date : = Date(Max([PO Date]))

Prev Date : =Date(Max([PO Date] ,2 ))

Max Price : =FirstSortedValue([Unit Price], -[PO Date])

Prev Price : =FirstSortedValue([Unit Price], -[PO Date] ,2)

QlikAngel
Partner - Creator
Partner - Creator
Author

HI,

I HAVE TRIED THIS WITH LIVE DATA..

DATE IS WORKING PERFECTLY

BUT FOR PRICE THERE IS A FORMULA LIKE BELOW

SUM( QTY * UNIT_PRICE) + SUM(TAX_AMOUNT)

HOW IT WILL WORK WITH FIRST SORTED VALUE

AS I HAVE TRIED BUT IT SHOWS ERROR IN EXPRESSION.

SUGGESTIONS ARE WELCOME

tresesco
MVP
MVP

Try like:

=FirstSortedValue(Aggr(SUM( QTY * UNIT_PRICE) + SUM(TAX_AMOUNT),Org, ItemCode, [PO Date]), -[PO Date])

QlikAngel
Partner - Creator
Partner - Creator
Author

iTS WORKING BUT FOR SOME OF RECORDS VALUES ARE COMING & FOR SOME ITS NOT..

wHAT WILL BE THE CAUSE?

tresesco
MVP
MVP

May be there are cases where max dates have same max value more than once. If so, try with distinct like:

FirstSortedValue( Distinct Aggr(SUM( QTY * UNIT_PRICE) + SUM(TAX_AMOUNT),Org, ItemCode, [PO Date]), -[PO Date])


Note: you would get syntax error, just ignore that.

QlikAngel
Partner - Creator
Partner - Creator
Author

Thank u so much .. its working perfectly