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: 
alexis
Partner - Specialist
Partner - Specialist

Variable substitution in Set Analysis

I have the following set analysis formula (only a part showing...

I want to replace what you see in bold below withe contents of a table column (let's call it Field1) that contains values such as 'CM','CY' etc ....

= count({<[CM] = {1}, [CCS_Subscriber.CCS_Subs

I know the answer is something of the form:

= count({<[$(=Field1)] = {1}, [CCS_Subscriber.CCS_Subs

but cannot seem to get it to work. Any ideas?

Thanx in advance


1 Solution

Accepted Solutions
Not applicable

May be this will help you

View solution in original post

9 Replies
ashfaq_haseeb
Champion III
Champion III

Hi

MAy be try like below

= count({<["$(=Field1)"] = {1}, [CCS_Subscriber.CCS_Subs


Regards

ASHFAQ

Not applicable

May be this will help you

alexis
Partner - Specialist
Partner - Specialist
Author

Thanks Ashfaq - does not seem to work for some reason.....var1.png

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Does Field1 have a single distinct value in the context for this expression? If the expression is inside table, remember that the set analysis context is global (ie you cannot have Field1 evaluated on a row by row basis).

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
alexis
Partner - Specialist
Partner - Specialist
Author

Hi Himark

Thank you for your example and the effort in trying to help me - look at the example below for a fuller explanation..

Alexis

ashfaq_haseeb
Champion III
Champion III

Hi,

Can you attache sample qvw file with expected output.

Regards

ASHFAQ

alexis
Partner - Specialist
Partner - Specialist
Author

Hi Jonathan,

Here is a more detailed explanation.

My code at the moment may have

= count({<[CCS CM] = {1}, [CCS_SubscriberStatusActive] = {1}>}SubscriberKey)

Elsewhere I may have a formula of the form:

= count({<[FSB CM] = {1}, [FSB_PackageStatus] = {1}>}PackageKey)

Both would give "current month" figures - as you may have guessed I have several calendars - I have a CCS calendar and an FSB calendar - hence the flags "CCS CM" and "FSB CM"

I have other flags in my calendars such as "xxx CY" for current year, "xxx CQ" for "current Quarter" etc...

I want to give the user the option to select from a list of metrics from a drop down list that will contain:

- Current Year

- Current Quarter

- Current Month

I created a table

CurrentOptionsMap:

LOAD * INLINE [

    TimeText, TimeVariable

    'Current Month', 'CM'

    'Current Year', 'CY'

    'Current Quarter', 'CQ'

];

When the user selects an option I want it to use that metric to construct say "CCS CQ" for the current quarter where the CCS calendar is used etc ... so in the first example it will be something like:

= count({<[CCS "$(=TimeVariable)"] = {1}, [CCS_SubscriberStatusActive] = {1}>}SubscriberKey)

and in the 2nd:

= count({<[FSB "$(=TimeVariable)"] = {1}, [FSB_PackageStatus] = {1}>}PackageKey)

etc...

Hope this is clearer..

alexis
Partner - Specialist
Partner - Specialist
Author

just provided (after an edit!) a detailed explanation....

alexis
Partner - Specialist
Partner - Specialist
Author

Thank you Himank -

Your solution works .. although not ideal as I have a listbox with values such as:

CM

CY

CQ etc ...

(equivalent to your 'AA' and 'B B') - can you think of a way to improve it by having a description for the user to choose from ... in your example a listbox that will have:

- Description of AA

- Description of B B etc