Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
kristien
Partner - Contributor III
Partner - Contributor III

How add a filter not related to the datamodel but to be used in master item measure to determine a certain condition in calculation

Hello,

I'd like to add a filter where the user can select between two options.

The options itself are not related to any data in the data model.

I want to make a masteritem that calculates a total, but with a condition: the result will be different if the user select option A or option B.

That way, on the chart I can show a linechart of that masteritem, and depending the option that the user selected another line is displayed.

A simple Example:

I Add in my script 

Switch:
Load * Inline [
Switch
A
B
];

I will use this field to put on the dashboard as a filter. You can select A or B. But there are no relationships with the data.

I make a Master item Measure, ie. TotalSwitch that could be:

If(
GetCurrentSelections(Switch)='A' or GetSelectedCount(Switch) = 0
, Count({<Field1={'1'}>} distinct Field2)
, Count({<Field3={'1'}>} distinct Field2) 
)

The conditions cannot be selected in the database.

But this doesn't work because when I select A in the Switch-filter, GetSelectedCount(Switch) is not 1 but a certain number of records (all)

How could do that 

The perpose is: the user can select an option: A or  B 

and in the line chart, another line will be shown according to what the user has selected.

 

 

Labels (3)
1 Solution

Accepted Solutions
kristien
Partner - Contributor III
Partner - Contributor III
Author

I have found a solution.

What I stated in my question is not completely correct: GetSelectedCount(Switch) was correct (1) but the  performance was too poor to show the Master Item Measure and at the end it did not show but I got an error.

I added a numeric value to my filter field and implement that in may master item and this works better

In my script I have now something like:

Switch:
Load * Inline [
Switch, SwitchNr
A, 1
B, 2
];

And in the Master Item Measure something like

If(
Max(SwitchNr) = 2
, Count({<Field1={'1'}>} distinct Field2)
, Count({<Field3={'1'}>} distinct Field2) 
)

(It is in version qlik Sense June 2018 )

View solution in original post

1 Reply
kristien
Partner - Contributor III
Partner - Contributor III
Author

I have found a solution.

What I stated in my question is not completely correct: GetSelectedCount(Switch) was correct (1) but the  performance was too poor to show the Master Item Measure and at the end it did not show but I got an error.

I added a numeric value to my filter field and implement that in may master item and this works better

In my script I have now something like:

Switch:
Load * Inline [
Switch, SwitchNr
A, 1
B, 2
];

And in the Master Item Measure something like

If(
Max(SwitchNr) = 2
, Count({<Field1={'1'}>} distinct Field2)
, Count({<Field3={'1'}>} distinct Field2) 
)

(It is in version qlik Sense June 2018 )