Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Saurabh07
Contributor III
Contributor III

Dynamically change the measures in table based on selection in filter

Hello Gurus,

I am looking for something like this in Qlik, I need to dynamically change the dimensions to be changed based on from which filter I am selecting values from. This seems a bit confusing, hence mentioned is the structure of my data.

Parent SegmentSegmentValue
Segment_FSegment_A60
Segment_FSegment_A35
Segment_FSegment_A60
Segment_FSegment_A60
Segment_FSegment_A60
Segment_FSegment_B60
Segment_GSegment_D85
Segment_GSegment_C135
Segment_GSegment_C110
Segment_GSegment_D60
Segment_GSegment_C35
Segment_GSegment_D60

So at top I have two filters, one each for Segment and Parent Segment. I would be making selection in either of the table at a time only. 

So if I select 'Segment F' in Parent Segment filter, below is the desired result;

dimensionTotal Value
Segment_A275
Segment_B60

But, if I clear all the filters and this time select 'Segment C' in Segment filter, below is the desired result;

dimensionTotal Value
Segment_C280

 

So as you see I'm looking to change the dimension based on, from which filter I am making selection. I have tried few things out, but not with much luck! Is this possible in Qlik and if yes, can anyone please help me out here?

2 Solutions

Accepted Solutions
Taoufiq_Zarra

@Saurabh07  try this :

in dimension:

=if(getselectedcount([Parent Segment])>0,
aggr(only(Segment),Segment),if(getselectedcount(Segment)>0,
Segment
))

 

in measure :

=sum(Value)

 

output:

select F in parent

Capture.PNG

select c in segment

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

Saurabh07
Contributor III
Contributor III
Author

@Taoufiq_Zarra  Hey, you are magician! I have started believing that nothing is impossible in Qlik. I have made slight change to the formula though, but yours is working fine as well!! Thank a ton!

=if(getselectedcount([Parent_Segment])>0,
aggr(only([Parent_Segment]),[Parent_Segment]),if(getselectedcount(Segment)>0,
Segment
))

 

View solution in original post

2 Replies
Taoufiq_Zarra

@Saurabh07  try this :

in dimension:

=if(getselectedcount([Parent Segment])>0,
aggr(only(Segment),Segment),if(getselectedcount(Segment)>0,
Segment
))

 

in measure :

=sum(Value)

 

output:

select F in parent

Capture.PNG

select c in segment

Capture.PNG

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Saurabh07
Contributor III
Contributor III
Author

@Taoufiq_Zarra  Hey, you are magician! I have started believing that nothing is impossible in Qlik. I have made slight change to the formula though, but yours is working fine as well!! Thank a ton!

=if(getselectedcount([Parent_Segment])>0,
aggr(only([Parent_Segment]),[Parent_Segment]),if(getselectedcount(Segment)>0,
Segment
))