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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Rehan
Creator III
Creator III

Previous Date Issue

I have a Extraction Date field but it has no sequence to it. For example I have dates like

05/1/2019

03/1/2019

2/1/2019.

I always want the Max Date and the  Previous from Max Date. In this case I need 5/1/2019 and 3/1/2019. I know how to get 5/1/2019 but how will get  3/1/2019. 

15 Replies
Vegar
MVP
MVP

The issue with my previous suggestion was that it was taking the second largest date in the selection. So if you where selecting only one date there where no second largest date in your selection.  If you where to select two or more dates it will work as intended. 

To meet your need I need to tell the modifier to consider all [ETL Date] smaller than the selected value. A modifier inside the modifier. 

only({< [ETL Date]={"$(=MAX({<[ETL Date]= {"<=$(=MAX([ETL Date]))"} >}[ETL Date],2))"} >} [ETL Date])

Rehan
Creator III
Creator III
Author

I am currently using the below expression to get the previous date. It works fine if I make a selection in ETL Date Field.

Date(If(GetSelectedCount([ETL Date]) >0,
Aggr(Above(Max({<[ETL Date]>} [ETL Date])), [ETL Date]),
Max({<[ETL Date]>}[ETL Date], 2)))

I Created a field called ETL  Month from ETL Date . ETL Month is in the format "May 2019". If I select the ETL Month this expression doesnt work . I modified teh expression as 

Date(If(GetSelectedCount([ETL Month]) >0,
Aggr(Above(Max({<[ETL Date]>} [ETL Date])), [ETL Date]),
Max({<[ETL Date]>}[ETL Date], 2)))

Any idea what am I doing wrong here ?

Vegar
MVP
MVP

Try to expand your set modifiers with the new month fiels. Like this.

{<[ETL Date], [ETL Month]>} 

Rehan
Creator III
Creator III
Author

Tried it doesn't work, Its not changing the values its staying at the Previous month value no matter what I select in ETL Month

Rehan
Creator III
Creator III
Author

I guess I Spoke too soon, Its working in a variable, but when I use that variable in  SET analysis , it does not  work. Means by default u see previous ETL month but when you make a selection in ETL month it blanks out

Vegar
MVP
MVP

Try this:

Date(If(GetSelectedCount([ETL Month])>0,
  max(Aggr(Above(Max({<[ETL Date], [ETL Month]>} [ETL Date])), [ETL Date])),
Max({<[ETL Date], [ETL Month]>}[ETL Date], 2)))