Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

AGGR Function Not working for Partial Sum Percentages

Good Morning,

I am developing an app in which the users requirements are to calculate the YoY % Growth for different sales categories by month. Since the user wanted to be able to expand and collapse field dimensions (i.e. Category and Month) I used a Pivot table to display the data. One nuance in the requirements was that the user wanted to be able to see Actuals and Forecast. (i.e. Actual sales would be represented by months that have already completed while current month and future months would be displayed as Forecast sales.) The SUM(AGGR( function works fine with the IF Statement I have in terms of 2018 sales, 2017 sales and YoY Sales Difference. However when I use the AGGR function for the YoY % Growth, the partial sum total is incorrect. In my example below the partial sum reads -40% when it should be +26%.

I need assistance getting correct value shown on the YoY % Growth line.

If anything is this request is confusing I'd be glad to help clarify.

Thanks in advance.

-B-

1 Solution

Accepted Solutions
YoussefBelloum
Champion
Champion

Hi,

try this as an expression for YoY %:

=(SUM(AGGR(IF(SUM({<YEAR={'2018'},SCENARIO={'ACTUALS'}>}UNITS)=0,SUM({<YEAR={'2018'},SCENARIO={'FORECAST'}>}UNITS),SUM({<YEAR={'2018'},SCENARIO={'ACTUALS'}>}UNITS)),MONTH, CATEGORY))

-

SUM(AGGR(IF(SUM({<YEAR={'2017'},SCENARIO={'ACTUALS'}>}UNITS)=0,SUM({<YEAR={'2017'},SCENARIO={'FORECAST'}>}UNITS),SUM({<YEAR={'2017'},SCENARIO={'ACTUALS'}>}UNITS)),MONTH, CATEGORY)))

/

SUM(AGGR(IF(SUM({<YEAR={'2017'},SCENARIO={'ACTUALS'}>}UNITS)=0,SUM({<YEAR={'2017'},SCENARIO={'FORECAST'}>}UNITS),SUM({<YEAR={'2017'},SCENARIO={'ACTUALS'}>}UNITS)),MONTH, CATEGORY))

View solution in original post

3 Replies
YoussefBelloum
Champion
Champion

Hi,

try this as an expression for YoY %:

=(SUM(AGGR(IF(SUM({<YEAR={'2018'},SCENARIO={'ACTUALS'}>}UNITS)=0,SUM({<YEAR={'2018'},SCENARIO={'FORECAST'}>}UNITS),SUM({<YEAR={'2018'},SCENARIO={'ACTUALS'}>}UNITS)),MONTH, CATEGORY))

-

SUM(AGGR(IF(SUM({<YEAR={'2017'},SCENARIO={'ACTUALS'}>}UNITS)=0,SUM({<YEAR={'2017'},SCENARIO={'FORECAST'}>}UNITS),SUM({<YEAR={'2017'},SCENARIO={'ACTUALS'}>}UNITS)),MONTH, CATEGORY)))

/

SUM(AGGR(IF(SUM({<YEAR={'2017'},SCENARIO={'ACTUALS'}>}UNITS)=0,SUM({<YEAR={'2017'},SCENARIO={'FORECAST'}>}UNITS),SUM({<YEAR={'2017'},SCENARIO={'ACTUALS'}>}UNITS)),MONTH, CATEGORY))

Anonymous
Not applicable
Author

Youssef,

The formula worked perfectly. Thanks for your assistance!

-B-

YoussefBelloum
Champion
Champion

You're welcome

Good luck