Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
narband2778
Creator II
Creator II

Trying to use a variable In Set Analysis

Hello Everyone,

I have created a Variable in the Variables

vCurrentSelection =SubField(GetCurrentSelections(), ':',2)

and now I am trying to use the variable in Set analysis, but it is not working

=Count({<[Session  Name] = {"$(=vCurrentSelection)"}>}[Session  Name])

Can someone help me with this.

thanks in advance.

Naresh

43 Replies
sunny_talwar

How about this

=Count({<[Session  Name] = p($(='[' & SubField(GetCurrentSelections(), ':', 1)))>} [Session  Name])

narband2778
Creator II
Creator II
Author

Hi Chanty,

I'll be selecting only one value at time.

In Brief, my requirement is, If I select  a value from one filed then I want to count the same value in 10  different fields.

Thanks,

Naresh

narband2778
Creator II
Creator II
Author

No Sunny. Getting Null value.

@1.png

sunny_talwar

My bad... can you try this

=Count({<[Session  Name] = p($(='[' & SubField(GetCurrentSelections(), ':', 1) & ']'))>} [Session  Name])

narband2778
Creator II
Creator II
Author

You are a rock star mate .

I am trying to understand this, when you gave 1 as third parameter for SubField() then it should return the Field name right!

But, why it wasn't working when we put the =SubField(GetCurrentSelections(),':',2) in a variable.

If you don't mind can you explain me.

Thanks,
Naresh

sunny_talwar

What I am using is slighly different then what you were trying to do... In your example, you selected XYZ in Operating Name, right? and want to count all Session Name with the value XYZ?

You were trying to do this

=Count({<[Session  Name] = {'XYZ'}>} [Session  Name])

I did this

=Count({<[Session  Name] = p([Operating Name])>} [Session  Name])

Basically, what p() function does is that it looks for matching values in Operating Name field which are present in Session Name. Since, you have selected XYZ in Operating Name, it indirectly looks to count XYZ in Session Name. Read more about it here Indirect Set Analysis for P() and E()

So, by using SubField() with 1... i picked the field name... rather than it's value and then used dollar sign expansion to convert the string Operating Name to the field Operating Name.


narband2778
Creator II
Creator II
Author

yeah, makes sense.

thanks once again.

Thanks,

Naresh

sunny_talwar

No problem at all

narband2778
Creator II
Creator II
Author

Hi Sunny,


What if I want to select "XYZ" from any field, still want to count the times it appears in different fields. Sorry, to bug you again.

Thanks,

Naresh

sunny_talwar

Select "XYZ" from any field and still want to count the times it appears in different fields? Which different fields?