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: 
Anonymous
Not applicable

Data for max year minus four years

Hello Everyone,

Here are my requirements.

I have two measures Sales and Revenue. My measure is a date field. I want to shot the Sales and Revenue as a line in a line graph for the last four years. I am using this expression and it is giving me last four year data from the current year.

=if(Year([Date Spread])>year(today())-4,date#(Year([Date Spread])))

But another requirement is if I select a customer who has sales and revenue data only for 2003, the graph should show the data for 2003, but when I select the customer from 2003 it does not fetch any data. I know it is because I am pulling the data from current year.

Any help is appreciated. Thanks in advance.

5 Replies
jerifortune
Creator III
Creator III

Check your if statement. You limited the chart to show 2014 and above, therefore 2013 and below are not expected

Anonymous
Not applicable
Author

Yes, I know that. Can you help with the statement that will fix this problem?

Anil_Babu_Samineni

You may define it as this?

=if(Year([Date Spread])>year(today())-4,date#(Year([Date Spread])), Date#(Year([Date Spread])))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

When I do not select any year, on the graph, it shows the the median of sales and revenue which are linked variables. So if I use the solution you have provided above, it shows all the years if I do not select any customer. But I only want four years as a default.

So my solution should be something like that will keep the default view of last four years, but if I select one customer it should show the Sales and revenue for that one customer irrespective of year.

jerifortune
Creator III
Creator III

I do use two options.

Option 1: Use bookmark to select the last for years as default filter.

Option 2: Have two charts, the first chart is locked to fours and the second will respond to user selection