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

Issue with Set Analysis with Variable

When utilizing the expression:
({1< pt_Segment = {"$(=$(vSegment))"}>} Count(distinct pt_IPNO&pt_YHNO))

the variable vSegment, which is defined as:
Replace(GetFieldSelections(pt_Segment),', ','","')

It's observed that when no selection is made in the filter, the resulting value is 0. But my requirement is if you don't pick anything from the filter, I want to include all values from the "pt_Segment" field.

Any help is greatly appreciated.

Labels (3)
1 Solution

Accepted Solutions
marcus_sommer

I assume that by adding a DISTINCT statement into the concat() by the suggestion from @qv_testing that the performance should be increase significantly.

Beside this you could simplify the approach by using p(), like:

Count({1< pt_Segment = p(pt_Segment) >} distinct pt_IPNO&pt_YHNO)

 

View solution in original post

6 Replies
qv_testing
Specialist II
Specialist II

try this

=count({<pt_Segment={$(=concat(chr(39) & pt_Segment & chr(39),',') )}>}distinct pt_IPNO&pt_YHNO)))

yh2023
Contributor III
Contributor III
Author


It's working, but it's taking a really long time to load. Can you suggest a different approach?

anat
Master
Master

=count({<pt_Segment={$(=concat(distinct chr(39) & pt_Segment & chr(39),',') )}>}distinct pt_IPNO&pt_YHNO)))

marcus_sommer

I assume that by adding a DISTINCT statement into the concat() by the suggestion from @qv_testing that the performance should be increase significantly.

Beside this you could simplify the approach by using p(), like:

Count({1< pt_Segment = p(pt_Segment) >} distinct pt_IPNO&pt_YHNO)

 

yh2023
Contributor III
Contributor III
Author

Thank you, it works!! 

Since p() works effectively, can it be considered as a replacement for the getfieldselection() ?

marcus_sommer

For the majority of use-cases p() could be regarded as replacement for getfieldselections() but the logic behind the features and their possibilities are different.

p() and it's reverse function e() return the possible/excluded index-values (only the TRUE/FALSE state of a value and not the values itself) and not the active selected values which means p() and e() are working against the entire data-set and not only against a single field.