Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Year comparison in bar chart

Hello,

I asked almost the same question . Sum of the same companies in different years

but now, I want to add something. I want to compare the same periods of these years.

For example,

Today is 28 February. And I want to compare the data from January 1 to February 28 in these years.

Sum({<Company = p({<Year = {"$(=Max(Year) - 1)"}>})>}Measure)

Sum of the same companies in different years

How this formula can be changed ?

Also,

I want to compare all the companies that are in these years(2016,2017,2018)  If I add another year, for example, 2015, it should compare only the companies which are in all these 4years)

I compare these periods -- Year( as dimension)

  Measure :=SUM({$<Date = {'>=$(=YearStart(Today()))<=$(=MonthEnd(Today()))'}>}FactSoldAmount)                                      Measure:=SUM({$<Date = {'>=$(=YearStart(AddYears(Today(),-1)))<=$(=MonthEnd(AddYears(Today(),-1)))'}>}FactSoldAmou         Measure:=SUM({$<Date = {'>=$(=YearStart(AddYears(Today(),-2)))<=$(=MonthEnd(AddYears(Today(),-2)))'}>}FactSoldAmount)

but I can't unite it with the formula that calculates the same companies in these years.

25 Replies
Anonymous
Not applicable
Author

It is an extension.  Ok, I will try by other way. And in these formulas we compare the period, how can we compare the years regarding the max(Date) information ? how the period could be changed by the max(Date) ??

I try to change the period(in all measures) by this {"=max(date)"}.  Will it work properly ?


sunny_talwar

I guess replace all Today() with Max(date) and it should work....

Anonymous
Not applicable
Author

=Sum({$<Year,Date = {">=$(=YearStart(Max(date)))<=$(=MonthEnd(Max(date)))"}>} FactSoldAmount)

=Sum({$<Year, Date = {">=$(=YearStart(AddYears(Max(date), -1)))<=$(=MonthEnd(AddYears(Max(date), -1)))"}, BranchID = p({<Year = {"$(=Max(Year))"}>})>} FactSoldAmount)

=Sum({$<Year, Date = {">=$(=YearStart(AddYears(Max(date), -2)))<=$(=MonthEnd(AddYears(Max(date), -2)))"}, BranchID = p({<Year = {"$(=Max(Year))"}>})>}FactSoldAmount)

Thank you very much, it works. but now I have another problem. it shows only the year and last year that I select. I want to show all the year

sunny_talwar

All years? I have no idea what you mean... you will have to assume that I don't know anything...

Anonymous
Not applicable
Author

Sorry, I don't explain well and sorry to bothering you. I mean When I select 2018 it shows me 2016,2017 and 2018 years' compare in the bar chart. When I select 2017 it shows me only 2016 and 2017 (I want to show 2018too) I had the same problem up in this discussion and you helped me that's why I asked. Sorry again and thanks a lot for your help in everything in these days

sunny_talwar

Oh, that might be because we have coded to look back in time....

1) expression is for max year

2) expression is for max year -1

3) expression for for max year - 2

when you select 2017, it will show 2017, 2016 and 2015 (assuming you have data for all these three years)