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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
akraman
Contributor II
Contributor II

Set Analysis to lock a Chart with specific dates

I am trying to lock a chart viz with a specific date range, in YearQuarters three years ago from today.  I tried this with setting the dimension in the chart itself with:

=If([%DateKey.autoCalendar.YearQuarter] >= AddYears(Today(), -3), [%DateKey.autoCalendar.YearQuarter])

but when date selections are made in filterpans for year, month etc. the chart changes.

Is there a way to change a master item such that only the past 3 years are shown on a chart for that measure?

i.e. Revenue = sum([Invoice Revenue]*[FX])

can become something like

RevenueLastThree

= Sum(
{<
[Invoice Date] = {">=$(=Date(AddYears(Today(), -3))) <=$(=Today())"}
>}
[Invoice Revenue] * [FX]
)

Labels (4)
3 Replies
Mark_Leifeld
Partner - Creator
Partner - Creator

Is your only problem, that the measure is still reacting to other filters ? 

Just use "1" as set identifier. Qlik will ignore all other filter. 

https://help.qlik.com/en-US/sense/May2024/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/SetAnalysi...

 

Sum(
{  1 <
[Invoice Date] = {">=$(=Date(AddYears(Today(), -3))) <=$(=Today())"}
>}
[Invoice Revenue] * [FX]
)

akraman
Contributor II
Contributor II
Author

It's a bit more than that, while I understand what 1 will do at the set identifier, it is actually overstating the revenue by Billions.  I think I need to clear individual date fields and have the aggregation work out the same as it is for straight "Revenue". I simply want Revenue = sum([Invoice Revenue]*[FX]) over the last three years, in year-quarters in a bar graph that does not change with changes to filter panes. I hope that makes sense and I appreciate the help!

akraman
Contributor II
Contributor II
Author

Could this be accomplished with Alternate States? i.e. Alt State called "LastThreeYears"