Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
@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]
Hi @Amit_B
Not sure I understand, but that looks as simple as:
{<Year={'$(vYearCS)'}>}([MasterItem])
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)/
vYearCS takes just 1 year or 1or more years?
Hi,
It is take one year.
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:
@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]
I understand what was my mistake was, this is really the answer.
Thanks.