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: 
Sunkanx
Contributor
Contributor

How to show only dates 'MM.YYYY' for the last 5 months as dimension

Hello,

I have a question about dates in dimension.  What i want to do is to show last 5 months as dimension in a bar chart, as my file is growing i don't want to show all the available dates, but only the last 5 month.  

What i have for now (not working) is below code:

=If(([Cycle Date] > {$<[Cycle Date] = {$(=date(AddMonths(max([Cycle Date]),'-5',0),'MM.YYYY'))}>}),date([Cycle Date],'MM.YYYY'),Null())

This should only show the dates that are from max month to -5 months, but i get invalid dimension in bar chart and i get all the dates in a table when the formula is shown as a measure. 

Sunkanx_0-1600945730125.png

Can someone please help me with this?

Thank you in advance.

 

Labels (1)
1 Solution

Accepted Solutions
Kushal_Chawda

@Sunkanx  try below

date(aggr(only({$<[Cycle Date] = {">$(=date(AddMonths(max([Cycle Date]),'-5')))<=$(=date(max([Cycle Date])))"}>}[Cycle Date]),[Cycle Date]),'MM.YYYY')

View solution in original post

2 Replies
Kushal_Chawda

@Sunkanx  try below

date(aggr(only({$<[Cycle Date] = {">$(=date(AddMonths(max([Cycle Date]),'-5')))<=$(=date(max([Cycle Date])))"}>}[Cycle Date]),[Cycle Date]),'MM.YYYY')
Sunkanx
Contributor
Contributor
Author

This is exactly what i needed. Thank you so much. I had to fix the formatting in the part where you defined between dates. Final solution is: 

date(aggr(only({$<[Cycle Date] = {">$(=date(AddMonths(max([Cycle Date]),'-5'),'MM.YYYY'))<=$(=date(max([Cycle Date]),'MM.YYYY'))"}>}[Cycle Date]),[Cycle Date]),'MM.YYYY')

Null values excluded