Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
simonagheo
Contributor III
Contributor III

Calculate percent by dimension

Hello,

I have a table that stores some dimension codes and their values:

DimensionValue
D110
D190
D220
D435
D45
D620

 

and another table that stores their names.

I need a  table with their sum but I also have to insert other dimensions that represent some percents based on the existing ones, like D3, D5, D7.

DimensionNameValue
D1Total100
D2Dim 220
D3Dim 2 %20%
D4Dim 440
D5Dim 4 %40%
D6Dim 620
D7Dim 6 %20%

 

I tried to make a pivot table with the following expression:

=if(Match(Dimension,'D3'),num(sum({<Dimension={'D2'}>}Value)/sum({<Dimension={'D1'}>}Value),'#.##0%',',','.'),

if(Match(Dimension,'D5'),num(sum({<Dimension={'D4'}>}Value)/sum({<Dimension={'D1'}>}Value),'#.##0%',',','.'),

f(Match(Dimension,'D7'),num(sum({<Dimension={'D6'}>}Value)/sum({<Dimension={'D1'}>}Value),'#.##0%',',','.'),

,num(sum(Value),'#.##0',',','.'))))

but this isn't working. 

Can you help me find a better solution for my problem?

Thank you!

Labels (1)
11 Replies
simonagheo
Contributor III
Contributor III
Author

No, it is not the solution I needed. I didn't solve the problem. 

Thank you!

simonagheo
Contributor III
Contributor III
Author

Thank you, but it is not the solution I needed, because D3 should be D2/D1, so, when

D1=80,

D2=20,

D3 should be D2/D1=20/80=25%, and your solution calculates D3 as 20%.

simonagheo_0-1610449836073.png