Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to use max(Date) on a date range in a Bar Chart

I have to show "GDP" values for each year in a Bar Chart.There are multiple records for "GDP" with different "As of Date" for each year.I have to show "GDP" value for each year only from the latest(maximum) "As of Date".There is a year filter and the requirement is that once a year is selected I need to show the data starting from 4 years before and 4 years after the selected dates in the Bar chart(eg if I select year "2014",data will be shown from 2010 to 2018 ).I am using the following expression in my chart:

=num(Round((avg({$<As_Of_Date={'$(vMax_As_Of_Date_GDP)'},Year_No = {">=$(vPrev4CurrentYear) <=$(vFuture4CurrentYear) "},Flag= {'GDP'},Country={'US'}>} GDP_Forecast)),0.1)/100,'#,##0.0%')

vMax_As_Of_Date_GDP=max({<Flag={'GDP'}>}As_Of_Date)

where vPrev4CurrentYear will give 4 years before and vFuture4CurrentYear will give 4 years after the selected year.If the "As of Date" is same for all the years then there is no issue.But if say "As of Date" for "2014" is different from "2013","2015" and "2016" then even if I select year "2015" in the filter, chart will show value for 2013,2015 and 2016 but not 2014.If I select year "2014" then I will get only one value for '"2014" and not the entire year range.I have attached the screenshots where in first case when "As of Date" is same I see data for the entire Year range but when "As of Date" is different I don't see the year for which "As of Date" is different.

Please help.

0 Replies