Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
avantime
Creator II
Creator II

Aggr(expression) gives 0 as a result

Hi, I have a problem with the expression below. I am trying to add a seasonality percentage to some product subgroups (not all, hence some seasonal product subgroups are null).

The expression works OK when the pivot is expanded to product subgroup level, but once I move to product group level, the totals turn to 0.

Aggr(

SUM(DISTINCT IF([Seasonal product subgroup]=[Product subgroup] AND NOT ISNULL([Seasonal product subgroup]),[Seasonality percent]))

,[Product subgroup],Month)

Hope I made myself clear , maybe you have a solution for me.

15 Replies
vinieme12
Champion III
Champion III

and the Previous one?

sum( TOTAL <[Product Group]>  Aggr(

SUM(DISTINCT IF([Seasonal product subgroup]=[Product subgroup] AND NOT ISNULL([Seasonal product subgroup]),[Seasonality percent]))

,[PRODUCT GROUP],[Product subgroup],Month))

or

sum( TOTAL <[PRODUCT GROUP], [Product subgroup],Month> Aggr(

SUM(DISTINCT IF([Seasonal product subgroup]=[Product subgroup] AND NOT ISNULL([Seasonal product subgroup]),[Seasonality percent]))

,[PRODUCT GROUP],[Product subgroup],Month))

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
avantime
Creator II
Creator II
Author

The same.. show zero for product groups with no seasonal product subgroups..

vinieme12
Champion III
Champion III

OH k, then that is correct isn't it?

because we are checking whether [Seasonal product subgroup]=[Product subgroup] ?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
avantime
Creator II
Creator II
Author

No, it`s not correct, I am multiplying this seasonal percentage with the current sales target, so the sales target becomes 0. It should show 1 if the Product subgroup is not seasonal.

vinieme12
Champion III
Champion III

then you are basically multiplying    0  * Target !

add an if()

if (  ourExpression = 0 , 1 , ourexpression) * Target

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
avantime
Creator II
Creator II
Author

That was kind of obvious.. Isn`t it? ) It worked, many thanks!