Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
msmichael
Creator
Creator

Use the top 5 dates that are smaller than selected date as dimension

Hi experts,

There are three fields in my data - Date, ProductId and Amount. On each date, there might be many ProductIds. The dates can go back to 1 year (meaning totally 365 distinct dates in Date field), something like below,

DateProductIdAmount
5/20/202010110
5/20/202010220
5/20/2020103100
4/30/202010450
4/30/202010112
4/30/202010385
4/30/202010241
4/15/202010110
4/15/202010235
4/1/202010432
4/1/202010270
3/31/2020......
3/31/2020  
3/20/2020  
3/20/2020  
3/15/2020  
...  

 

I have a list on Date field in my dashboard, user can choose one date to view products and amount. Now I need to add a bar chart which shows number of products for the most latest 5 days which are smaller than chosen date. 

For example, if user choose "4/30/2020", the x-axis on the bar chart should show dates 4/30/2020, 4/15/2020, 4/1/2020, 3/31/2020, 3/20/2020, y-axis should show number of productIds on the according date.

How can I do this? I am thinking about using calculated dimension on Dates but not sure how to do it.

 

Thanks,

Michael

1 Solution

Accepted Solutions
Brett_Bleess
Former Employee
Former Employee

See the following duplicate post for solution:

https://community.qlik.com/t5/QlikView-App-Development/Use-the-latest-5-dates-that-are-smaller-than-...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.

View solution in original post

2 Replies
vamsee
Specialist
Specialist

I am not sure about the dimension, you can try using Rank() in it. But, maybe try changing your expression to

Sum({<Date={"=rank(Max(Date),1,4)<6"}>}Amount)
Brett_Bleess
Former Employee
Former Employee

See the following duplicate post for solution:

https://community.qlik.com/t5/QlikView-App-Development/Use-the-latest-5-dates-that-are-smaller-than-...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.