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: 
kashaboinaraj
Creator
Creator

How to Accumulate all previous years in bar graph

Hi team,

 

I need help on  how to accumulate all previous years to show  into one bar and current year in another next bar, in a bar  graph.

 

Thanks,

Raj

Labels (3)
1 Solution

Accepted Solutions
Arek92
Contributor III
Contributor III

Hi Raj,

In the load script you can calculate a new field. For purpose of this answer let's name it  "IsCurrentYear".  This field will classify each record as current year or previous years. It will do the classification based on simple If statement. Sth like this:

If (Year(date)=Year(Today()), 'CurrentYear', 'PreviousYears') as IsCurrentYear

 

Then in your bar chart you can use this new field as a chart dimension.

 

Let me know if this was helpful,

Arek

View solution in original post

4 Replies
Arek92
Contributor III
Contributor III

Hi Raj,

In the load script you can calculate a new field. For purpose of this answer let's name it  "IsCurrentYear".  This field will classify each record as current year or previous years. It will do the classification based on simple If statement. Sth like this:

If (Year(date)=Year(Today()), 'CurrentYear', 'PreviousYears') as IsCurrentYear

 

Then in your bar chart you can use this new field as a chart dimension.

 

Let me know if this was helpful,

Arek

kashaboinaraj
Creator
Creator
Author

Thanks Arek!!

kashaboinaraj
Creator
Creator
Author

Hi Arek,

 

How  can we show the first bar as previous year cumulative value and next bar need to show all the month of the current year bar. 

 

Regards,

Raj

Arek92
Contributor III
Contributor III

I would suggest to slightly modify the previous formula using nested If statement:

If(Year(date)=Year(Today()), 'CurrentYear', 
  If(Year(date)=Year(Today())-1, 'PreviousYear', 'Other' ))

 

Then Years other than Current and Previous will be classified as 'Other'

Hope it helps