Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Eman
Contributor
Contributor

Dynamic dimensional scope

Hi all,

I'm trying to create a report composer where the users can create pivot tables by their own choosing which dimensions and expressions show in the table. 
Everything seems to work fine until I need to show the row relative values (%).

Absolute:

dim1dim2exp1exp2total
xa1090100
 b303060

 

Relative:

dim1dim2exp1exp2total
xa10%90%100%
 b50%50%100%

 

 

= Count(DISTINCT my_value) 
/
Count( TOTAL <dim1, dim2> DISTINCT my_value)

 

In this case i can easily define which are my dimensional scopes (dim1 and dim2) to obtain the correct relative value. But what about if user needs to add dim3? This change my formula to:

 

= Count(DISTINCT my_value) 
/
Count( TOTAL <dim1, dim2, dim3> DISTINCT my_value)

 

Is it possible to do it dynamically? 

I tried something like:

 

= Count(DISTINCT my_value) 
/
Count( TOTAL <GetFieldSelections(dim_selected)> DISTINCT my_value)

 

or using variables to get the selected fields or, even, converting total to set analysis but without any success.

Can somebody help me please?

 

Thanks in advance,
Emanuele

Labels (4)
1 Solution

Accepted Solutions
rubenmarin

Hi Emanuel, I think you attempt was close, can you try it using a $-expansion syntax?:

= Count(DISTINCT my_value) 
/
Count( TOTAL <$(=GetFieldSelections(dim_selected))> DISTINCT my_value)

Or using concat:

= Count(DISTINCT my_value) 
/
Count( TOTAL <$(=Concat(dim_selected,','))> DISTINCT my_value)

 

View solution in original post

2 Replies
rubenmarin

Hi Emanuel, I think you attempt was close, can you try it using a $-expansion syntax?:

= Count(DISTINCT my_value) 
/
Count( TOTAL <$(=GetFieldSelections(dim_selected))> DISTINCT my_value)

Or using concat:

= Count(DISTINCT my_value) 
/
Count( TOTAL <$(=Concat(dim_selected,','))> DISTINCT my_value)

 

Eman
Contributor
Contributor
Author

Hi Ruben,

first solution works properly! Thank you very much!