Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ramrongala
Contributor II
Contributor II

how to get previous record of max record

Hi Experts ,

Greetings!

I have below sample data 

Year MonthSales
2020/230
2020/550
2020/670
2020/890

 

Requirement: need to compare max month data(2020/8) and previous month data(2020/6) as dimensions .

i used below expression for

max month: max(YearMonth) showing 2020/8 (showing as expected)   

previous month/record: =date(max([YearMonth])-1,'YYYY/MM')

                                                   =date($<YearMonth = {$(=Max(YearMonth) – 2)}>},YYYY/MM)
                                                    =Previous(max(YearMonth))        

Please help to how i can show max month(2020/8) and previous record(2020/6) of max month     

Note: Year Month column not followed any series , if any sales are happen that month data comes into DB.

Labels (1)
1 Solution

Accepted Solutions
Taoufiq_Zarra

@ramrongala 

one of qlik's magic tricks :

Max(X) for max X, Max(X,2) for the second max of X

so you need :

MAX :

=Date(Max(Date#([Year Month],'YYYY/M')),'YYYY/M')

 

PREVIOUS:

=Date(Max(Date#([Year Month],'YYYY/M'),2),'YYYY/M')

 

output :

Capture.JPG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

1 Reply
Taoufiq_Zarra

@ramrongala 

one of qlik's magic tricks :

Max(X) for max X, Max(X,2) for the second max of X

so you need :

MAX :

=Date(Max(Date#([Year Month],'YYYY/M')),'YYYY/M')

 

PREVIOUS:

=Date(Max(Date#([Year Month],'YYYY/M'),2),'YYYY/M')

 

output :

Capture.JPG

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉