Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
aashok
Contributor III
Contributor III

Display only last 3 years in the chart and also in the title.

Hi , I have a requirement from the user

for a chart that compares the selected year vs the previous year data.

When it selects 2020 it should not compare with the previous year, since there is no data present for 2019 in the database.(only 3 years data present everytime in the database).

So , in the chart title it should display only "WSH Incidents (2020)" instead of (WSH incidents(2019 vs 2020).

aashok_1-1664978726311.png

(the highlighted yellow should not be displayed when selecting 2020)

where as if 2021 or 2022 is selected it should compare with the previous years and also should be seen in the title.

Currently the expression that I use is 

='WSH Incidents by Month ('& year(max([8_Year_of_incident]-1)) & ' vs ' & max([8_Year_of_incident]) & ')'

I was unsuccessful in re-writing the expression. Could help?thanks.

 

 

Labels (3)
1 Solution

Accepted Solutions
rdelagarde
Contributor III
Contributor III

Hi,

You can use an IF condition.

 

If(
   // if the selected year is equal to the smallest year
   year(max([8_Year_of_incident]))=year(min({1} [8_Year_of_incident])),

   // then only the selected date is displayed
   'WSH Incidents by Month (' & max([8_Year_of_incident]) & ')',

   // else both dates are displayed
   'WSH Incidents by Month ('& year(max([8_Year_of_incident]-1)) 
   & ' vs ' & max([8_Year_of_incident]) & ')'
)

 

 

View solution in original post

1 Reply
rdelagarde
Contributor III
Contributor III

Hi,

You can use an IF condition.

 

If(
   // if the selected year is equal to the smallest year
   year(max([8_Year_of_incident]))=year(min({1} [8_Year_of_incident])),

   // then only the selected date is displayed
   'WSH Incidents by Month (' & max([8_Year_of_incident]) & ')',

   // else both dates are displayed
   'WSH Incidents by Month ('& year(max([8_Year_of_incident]-1)) 
   & ' vs ' & max([8_Year_of_incident]) & ')'
)