Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
JoshPark
Contributor III
Contributor III

Bar Chart's Dimension show only this year and previous year

Hi everyone, 

I'm making a bar chart with (name of data field): 
- 2 dimensions: Month ([Date.autoCalendar.Month]) -> Year ([Date.autoCalendar.Year]); 
- 1 measure: Actual Sales ([Sales]) 

So far, the chart looks like this: 

JoshPark_0-1686218350852.png

However I would like to show only 2 bars of this year and last year. 

 

I have researched some solutions on the forum and tried to follow, but it seems not working for my case. 

Here are some examples of expressions I tried for the measure [Sales]: 

Source: https://community.qlik.com/t5/App-Development/Showing-only-this-year-and-the-previous-of-four-years/...

 

Sum ({$<Year={">=$(=max(Year)-1)"}>} Sales)

 

 Result (if follow directly, it still shows all): 

JoshPark_5-1686219508216.pngJoshPark_6-1686219537990.png

 

 

Sum ({$<[Date.autoCalendar.Year]={">=$(=max(Year)-1)"}>} [Sales])

 

Result: 

JoshPark_1-1686218895194.pngJoshPark_2-1686218924042.png

 

 

Sum ({$<[Date.autoCalendar.Year]={">=$(=max(Date.autoCalendar.Year)-1)"}>} Sales)

 

Result: 

JoshPark_3-1686219126741.pngJoshPark_4-1686219151849.png

 

Can anyone help to guide me where have I done wrong and how to fix it?

Labels (3)
1 Solution

Accepted Solutions
JoshPark
Contributor III
Contributor III
Author

I think I got one solution to use Set Analysis with OR condition applied to YearsAgo field: 

Sum ({< [Date.autoCalendar.YearsAgo]={'0'}> + <[Date.autoCalendar.YearsAgo]={'1'} >} Sales)

View solution in original post

1 Reply
JoshPark
Contributor III
Contributor III
Author

I think I got one solution to use Set Analysis with OR condition applied to YearsAgo field: 

Sum ({< [Date.autoCalendar.YearsAgo]={'0'}> + <[Date.autoCalendar.YearsAgo]={'1'} >} Sales)