Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
piter89
Contributor II
Contributor II

Sorting 2nd dimension and share - a simple task without a solution

Hello,

I have a problem with sorting the second dimension and the share of expanded rows in a pivot table. I had to use a calculated dimension for the second dimension. This gives me the ability to sort in the right order. 
My data:

LOAD * Inline [
 Dim1,    Dim2,   Value
 Germany, Diesel, 1200
 Germany, Petrol, 1500
 France,  Diesel, 800
 France,  Petrol, 300
]

My pivot table:

Dim1 =Aggr(Dual(Dim2, RowNo(TOTAL)), Dim1, Dim2) Sum(Value) Share  
France   1100 28.95%  
   Diesel 800 21,05%
800/1100 = 72,73%
 
   Petrol 300 7,89%
300/1100 = 27,27%
 
Germany   2700 71,05%  
   Petrol 1500 ...  
   Diesel 1200 ...  


Unfortunately, after applying a calculated dimension, I have an issue with the row share. 
I can calculate the total market share, but I want to calculate the share of expanded rows in the parent row. 

My expression for share measure:

If(Dimensionality() = 1,
	Sum(Value)/Sum(Total Value)
    ,
    Sum(Value)/Sum(Total<Dim2> Value)
)

 
This expression returns 100% for expanded rows. This works fine, if I change the calculated dimension to a normal dimension, but I lose the correct order of expanded rows.

Thanks in advance for your help.

 

 

 

Labels (1)
1 Solution

Accepted Solutions
LRuCelver
Partner - Creator III
Partner - Creator III

Column(1) / Pick(Dimensionality(),
	Sum(total Value),
    Only(Aggr(Sum(total <Dim1> Value), Dim1, Dim2))
)

View solution in original post

1 Reply
LRuCelver
Partner - Creator III
Partner - Creator III

Column(1) / Pick(Dimensionality(),
	Sum(total Value),
    Only(Aggr(Sum(total <Dim1> Value), Dim1, Dim2))
)