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: 
Olip
Creator
Creator

Aggr by two dimensions

Hello Experts,

Need help in sorting out this solution.

Requirement is to create a Percentage KPI by both the dimensions grouped by Dim 1 & 2.

KPI is for every combination of Dim B we need to find percentage against Dim 1

i.e for Dim 1 row 1 = 10/(10+30+50)


Furthermore there is a need to calculate percentile as well.

Sample data below:

Dim 1Dim 2Measure
One A10
One B30
One C50
TwoD90
TwoE1000
TwoF200
ThreeG700
ThreeH890
ThreeI12
ThreeJ123
ThreeK450
ThreeL800
- Eager to learn n grow,

Olip
1 Solution

Accepted Solutions
Olip
Creator
Creator
Author

Thanks Sunny.

The total does not help owing two Dimensions.

So i went with ' sum( (Measure)/aggr(nodistinct sum( Measure),Dim1)'

- Eager to learn n grow,

Olip

View solution in original post

8 Replies
sunny_talwar

May be this

Sum(Measure)/Sum(TOTAL <[Dim 1]>Measure)

YoussefBelloum
Champion
Champion

Hi,

find attached.

Hope it is what you're looking for

Olip
Creator
Creator
Author

Thanks Youssef!

Looks like both the formulae works. I tried the former.

Sum(PEB)/aggr(nodistinct sum(total <Segment>(PEB)),Segment)

&

Sum(PEB)/aggr(nodistinct sum( <Segment>(PEB)),Segment)

- Eager to learn n grow,

Olip
YoussefBelloum
Champion
Champion

Good,

but you should take one of these two:

Sum(PEB)/ Sum(total <Segment> PEB)


Or


Sum(PEB)/aggr(nodistinct sum(PEB),Segment)



in terms of performance, stalwar1‌ will maybe give us his feedback ?

sunny_talwar

I try to avoid Aggr() function as much as I can, but more recently, I have seen issues where TOTAL doesn't really work well and had to fall back to Aggr() with NODISTINCT. So, I would first try to see if TOTAL qualifier works, if not, then fall back to Aggr() with NODISTINCT.

Olip
Creator
Creator
Author

Sum(Measure)/ Sum(total <Dim 1> Measure) does not work as 'Sum(total <Dim1> Measure)' returns the same as a normal sum. Hence, aggr is the only option removing the total is an option though as the latter.

- Eager to learn n grow,

Olip
Olip
Creator
Creator
Author

Thanks Sunny.

The total does not help owing two Dimensions.

So i went with ' sum( (Measure)/aggr(nodistinct sum( Measure),Dim1)'

- Eager to learn n grow,

Olip
YoussefBelloum
Champion
Champion

this expression is wrong.

if you choose the Aggr alternative, you should use this:

Sum(Measure)/aggr(nodistinct sum(Measure),Dim1)