Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
chhavi376
Creator II
Creator II

Dividing two Aggr() Functions

District CodeProduct1Value

District 1

Prod11
Prod22
Prod33
District 2Prod14
Prod25
Prod36
Prod47

I want to calculate the district wise share for every product.

the expression i am using is:

num(aggr(Sum(Value), Products,District)/aggr(Sum(Value), District) ,'#,##0.0%' )

But, this expression is not working.

Could anyone please suggest a way

1 Solution

Accepted Solutions
rubenmarin1

Hi chhavi, I see two options:

- Use NODISTINCT:

num(aggr(Sum(Value), Product1,[District Code])/aggr(NODISTINCT Sum(Value), [District Code]) ,'#,##0.0%' )

- Do the percentage in only one aggr:

num(aggr(Sum(Value)/ Sum(TOTAL <[District Code]> Value), Product1,[District Code]) ,'#,##0.0%' )

View solution in original post

4 Replies
rubenmarin1

Hi chhavi, I see two options:

- Use NODISTINCT:

num(aggr(Sum(Value), Product1,[District Code])/aggr(NODISTINCT Sum(Value), [District Code]) ,'#,##0.0%' )

- Do the percentage in only one aggr:

num(aggr(Sum(Value)/ Sum(TOTAL <[District Code]> Value), Product1,[District Code]) ,'#,##0.0%' )

effinty2112
Master
Master

Hi Chhavi,

i don't think you need AGGR here at all:

District Code Product1 sum(Value)sum(Value)/sum(TOTAL <[District Code]> Value)
District 1Prod1116.67%
Prod2233.33%
Prod3350.00%
District 2Prod1418.18%
Prod2522.73%
Prod3627.27%
Prod4731.82%

cheers

Andrew

chhavi376
Creator II
Creator II
Author

Thanks Ruben.

It's working fine

chhavi376
Creator II
Creator II
Author

Andrew,

I was trying to calculate the district wise share for every product in the dimension(This will remain static for me).

Also, I had to create a Pivot table, and i did not want the contents of this static dimension to move with the scroll bar, therefore i could not use it as an expression.