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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Amit_B
Creator II
Creator II

Measures by variable

Hi,

How to write a measure that ignores the user selection only on the Year field, but uses a variable to set a specific year?

For Example:
* Year range in the model: 2022-2024
* The variable "vYearCS" can take the values within this range: 2022-2024
* Default value for vYearCS = Min(Year) = 2022
Data:
2022: Jan - 23, Feb - 31
2023: Jan - 43, Feb - 17
2024: Jan - 34, Feb - 29
User Selection: 2023-2024, Jan
Variable Value: 2022
So, the measure should be: {<Year={'$(vYearCS)'}, Year=>}[MasterItem] and 23 (for 2022-Jan).

Please Help.

Labels (7)
1 Solution

Accepted Solutions
Kushal_Chawda

@Amit_B  when you write set analysis it automatically ignores other selection and provides the set of values according to defined set modifier. In this case below should give you values for Year defined in variable no matter what selection is made on Year. Also, check if your master measure has any other set analysis which can take precedence over outer set, hence outer set can be override by inner set. See more about inner and outer set here

{<Year={'$(vYearCS)'}>}[MasterItem] 

View solution in original post

7 Replies
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @Amit_B 

Not sure I understand, but that looks as simple as:

{<Year={'$(vYearCS)'}>}([MasterItem])

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Amit_B
Creator II
Creator II
Author

Hi,
I tried this and it doesn't work.
I don't get any data unless 2022 is also selected in the filter pane (like 2023 & 2024)/

Qrishna
Master
Master

vYearCS takes just 1 year or 1or more years?

Amit_B
Creator II
Creator II
Author

Hi,
It is take one year.

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

It is difficult to advice on this without actually understanding your data model and additional selections you are applying. 

In short what I have given you should work. I am assuming that it is possible that some other selections are playing a role or simply your variable value does not pass required value or value you think it passes.

For us to be able to troubleshoot this we would need preview of what your variable expands to - you can check this by going to expression editior and observing expanded content of your expression like on the screenshot below:

Lech_Miszkiewicz_0-1730799385754.png

 

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Kushal_Chawda

@Amit_B  when you write set analysis it automatically ignores other selection and provides the set of values according to defined set modifier. In this case below should give you values for Year defined in variable no matter what selection is made on Year. Also, check if your master measure has any other set analysis which can take precedence over outer set, hence outer set can be override by inner set. See more about inner and outer set here

{<Year={'$(vYearCS)'}>}[MasterItem] 

Amit_B
Creator II
Creator II
Author

I understand what was my mistake was, this is really the answer.
Thanks.