Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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.

1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

Or

sum(  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.

View solution in original post

15 Replies
lironbaram
Partner - Master III
Partner - Master III

hi

have you tried to wrap the function with a sum function

sum(Aggr(

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

,[Product subgroup],Month))

avantime
Creator II
Creator II
Author

hi, tried it, still gives 0.

lironbaram
Partner - Master III
Partner - Master III

hi

can you post sample data with the table structure you have

or explain the table structure

avantime
Creator II
Creator II
Author

Unfortunately I cannot post a sample due to confidentiality issues.

If I expand the table to product subgroup level I get results:

   

Product GroupProduct Sub GroupMONTH12345678
PG1PSg1Target305460957383196221817774972418492724961670971
PSg2Target24618333814726143643794186648245677282944140115
PG2PSg3Target117936296263184027193911184876115335248524207129
PSg4Target19040522658831734643199324043204601169732293143
PSg5Target297457250278311145287273214073065728111668074
PSg6Target2133142033711136321465119045302248154511276011

If I contract the table to Product Group level I get all zeros:

   

Product groupMONTH123456789
PG1Target000000000
PG2Target000000000
vinieme12
Champion III
Champion III

Try adding [PRODUCT GROUP] TO AGGR() AND TOTAL

sum( TOTAL <[PRODUCT GROUP], [Product subgroup]> 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

Hi,

Did that, not working, I get the same sum for each Month column.

It`s still a progress, not getting zeros anymore

vinieme12
Champion III
Champion III

Then add month to total

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.
vinieme12
Champion III
Champion III

Or

sum(  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

Show zero on Product Groups that have no seasonal Product subgroups...