Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

Dimentionality

Hi Friends

I have a issue like this my below Pivot table does not calculate the % Correctly

Screenshot_1.png

In Total row 100% is not shown

When I Expand the Pivot table It also does not calculate correctly

Screenshot_2.png

Expression I used is as follows

If(Dimensionality() = 1, count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL DISTINCT{<CODE={'1','2','5'}>}POLICY_NO),

If(Dimensionality() = 2, count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL<REASON> DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)))

Pls help

1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

use a combination of Rowno() and Dimensionality() to identify if the Pivot is collapsed or expaned

=if(Dimensionality()=0 and (RowNo()=0 or isnull(RowNo()))

,count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL DISTINCT{<CODE={'1','2','5'}>}POLICY_NO),

if(Dimensionality()=1  // 1st Dimension is collapsed

,if(RowNo()>0 or isnull(RowNo())                // 1st Dimension is collapsed

,count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)

,if(RowNo()=0 ,count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL <REASON> DISTINCT{<CODE={'1','2','5'}>}POLICY_NO))  // Total for first Dimension when expanded

)

,if(Dimensionality()=2 // 1st Dimension is expanded

,if(RowNo()>0,count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL <REASON> DISTINCT{<CODE={'1','2','5'}>}POLICY_NO))    // individual row totals

)

)

)



expanded_collapsed.PNG

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

6 Replies
vinieme12
Champion III
Champion III

the Dimensionality() value for the last TOTAL row is 0 and in your expression you are only specifying conditions for Dimensionality 1 and 2 so also add an Else condition for last total row

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

i think this **<CORRECTION>**

=If(Dimensionality() = 2,

     count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL<REASON> DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)

,

If(Dimensionality() = 1,

     count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL<REASON,Vehicle_TYpe> DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)

,    

count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)

) )

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
upaliwije
Creator II
Creator II
Author

Thanks Vineeth,

It works for the 1st part of my question. Pls consider 2nd part also

vinieme12
Champion III
Champion III

can you post a sample?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
upaliwije
Creator II
Creator II
Author

Here I have attached my QV sample

vinieme12
Champion III
Champion III

use a combination of Rowno() and Dimensionality() to identify if the Pivot is collapsed or expaned

=if(Dimensionality()=0 and (RowNo()=0 or isnull(RowNo()))

,count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL DISTINCT{<CODE={'1','2','5'}>}POLICY_NO),

if(Dimensionality()=1  // 1st Dimension is collapsed

,if(RowNo()>0 or isnull(RowNo())                // 1st Dimension is collapsed

,count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)

,if(RowNo()=0 ,count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL <REASON> DISTINCT{<CODE={'1','2','5'}>}POLICY_NO))  // Total for first Dimension when expanded

)

,if(Dimensionality()=2 // 1st Dimension is expanded

,if(RowNo()>0,count(DISTINCT{<CODE={'1','2','5'}>}POLICY_NO)/count(TOTAL <REASON> DISTINCT{<CODE={'1','2','5'}>}POLICY_NO))    // individual row totals

)

)

)



expanded_collapsed.PNG

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.