Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Use of variable in set analysis

Hello everybody,

Today i got a problem with qlik,

I created i variable $(POC) that can take to value :'Yes' or 'No'

now i'm tryng use this variable to count a flied called  'Poche' when $(POC) = 'Yes'

so it'll count the number of 'poche' when $(POC)='Yes'.

my syntax is like that : count({<$(POC)={'Yes'}>} [Poche])

and it dosent work ! Somebody have a solution please ?

Thanx you

1 Solution

Accepted Solutions
stigchel
Partner - Master
Partner - Master

If $(POC) is an expression, can you try with

Count({<Poche={"=$(POC)='Qui'"}>} Poche)


With the assumption that the = sign is not included  in your variable POC. Also $ sign expansion is only evaluated at chart level, so not per row level of the dimension.

View solution in original post

11 Replies
sunny_talwar

I think what you want is something like this:

=Count({<Poche = {'$(POC)'}>}[Poche])

Not applicable
Author

Thx Sundidia for your answer,

But no, i want to count the number of 'poche' (it can be one,two or five for example ) when my variable $(POC)='Yes'.

you understand.?

thanks?

sunny_talwar

If I understand your correctly, try one of these:

1) =If(POC = 'Yes', Count(Poche)) or

2) =If($(POC) = 'Yes', Count(Poche))

HTH

Best,

Sunny

Not applicable
Author

I tried your solution, the syntax is good but is not exacly the solution, i explain you again

Each 'poche' has his $(POC) value ('Yes' or 'No'),and  I want to count the number of poche that has a his $(POC)= 'Yes'

thanks you very much

sunny_talwar

Is $(POC) a field or a variable? If it is not a field, then how does each Poche has its own $(POC)??? Do you have a sample that you can share??

Sunny

Not applicable
Author

Capture.PNG

here is a example, 'Yes' = 'Oui', No='Non', in this case , i want from my calculeated epression 1 as result

'(POC)' fields containt my variable $(POC).

Hope u understand better know, thanx

MarcoWedel

count({$<[(POC)]={'Oui'}>} [Poche])

sunny_talwar

Marco Wedel‌ not sure if (POC) is a field or an expression label. From the image it seems Expression to me, but I may be wrong.

swuehl
MVP
MVP

As I understand, you have a field called (POC) and a variable POC (be aware that $() is used for a so called dollar sign expansion of a variable, check the HELP for more details). A variable in QV is not connected to the data model.

Or are you referring to field (POC) as a variable (which some do, in a more statistics based context)?

If you have a variable and a field, try

=COUNT({$<[(POC)] = {'$(POC)'}>} [Poche])

or a distinct count:

=COUNT({$<[(POC)] = {'$(POC)'}>} DISTINCT [Poche])