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 over Year Calculation

Hi,

I am trying to show year on year(YoY) comparison in a straight table. But when the sum of a particular category is 0 in the previous year, it's not showing any value, even though the next year has a value

E.g.

2016 2017

0         100

I expect to see 100% increase

I tried using this formula but it's not working properly

if(Sum({$<Year = {2016}>}[USD Amount]) = 0, '100%',

(fabs(Sum({$<Year = {2017}>}[USD Amount]))-fabs(Sum({$<Year = {2016}>}[USD Amount])))/fabs(Sum({$<Year = {2016}>}[USD Amount])))

The formula works partly as it also shows 100% when 2017 value is 0

I need to add a condition where if both the years are 0, then it's 0%, otherwise calculate.

Any help is appreciated

Thanks,

Sunny

2 Replies
sunny_talwar

May be try this

If(Sum({$<Year = {2016}>}[USD Amount]) = 0,

     If(Sum({$<Year = {2017}>}[USD Amount]) = 0, '0%', '100%'),

          (fabs(Sum({$<Year = {2017}>}[USD Amount]))-fabs(Sum({$<Year = {2016}>}[USD Amount])))/fabs(Sum({$<Year = {2016}>}[USD Amount])))

Anonymous
Not applicable
Author

Thanks dude, it works