Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
sroettger
Partner - Contributor III
Partner - Contributor III

Set Analysis Restrict selection

Hi. I would like to count the total number of values from a field XMETXT, but at the same time consider the selection (in this case company code = Bukr).
So don't count over ALL values, but only the number of all values in a company code (even if further selections are added).
I tried it like this:
Count(Distinct {1} [XMETXT]) --> Then ALL is counted.

But I would like to have something like this, i.e. only the values from the company code that was selected.
Count(Distinct {1<Bukr={}>}Bukr} [XMETXT])

If no Bukr is given, the selection should then show EVERYTHING.

Is that understandable??!! I hope so!!!

Thank you!!!

Translated with www.DeepL.com/Translator (free version)

Labels (1)
3 Replies
durgesh22
Creator
Creator

@sroettger 

Try below expression .

count(distinct {1<$(=if(len('$(=GetFieldSelections(company_code))')>1,'company_code','company_code1'))={'Bukr'}>}XMETXT)

sroettger
Partner - Contributor III
Partner - Contributor III
Author

Thank you very much. I'll try it another way - step by step.
This code takes the BUKRS 0381 and counts up:
Count({$<[BUKRS]={'0381'}>}[XMETXT])

Now I want to take any value from the BUKRS field (instead of 0381), e.g. 0382, 0441, etc.

This code goes in the right direction - but does not work.

Count({$<[BUKRS]={'$(=GetFieldSelections([BUKRS]))')}>}[XMETXT])

Where is the error?

vinieme12
Champion III
Champion III

As below

=Count(Distinct {<CompanyCode=p(CompanyCode) >} [XMETXT])

 

But even without this, this is default Qlik behavior to only show associated data

If you select CompanyCode = BUKR, you will automatically be only counting any XMETXT values associated to companycode =BUKR

=count( [XMETXT]) will give you same result

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