Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a chart with one calculated measure and two dimensions (one line and one group).
I want a different label for each different Year (CY, PY and 2PY) on the first value of each series.
I have been able to generate the label only for the latest year with:
dual
(if(Week=1 AND Year=2024,
'CY',
if(Week=1 and Year=2023,'PY',' ')),
count(distinct [MyDim])
)
It seems that Qlik is evaluating the condition only for the current year. Is there an error in my formula or there is another approach?
Thanks!
Davide
Tried recreating this and here is what I got:
Measure used:
Dual(
If(Week > 1, ' ',
// Assign the Text here. Example:
Pick(Rank(Year), 'CY', 'PY', '2PY')
),
Count(distinct MyDim)
)
Make sure to set the Number formatting to "Measure Expression":
Here is the data I used:
Data:
NoConcatenate Load
RecNo() as Week
AutoGenerate 52;
Join Load * Inline [
Year
2022
2023
2024
];
Join Load
Floor(Rand() * 3) + 2022 as Year,
Floor(Rand() * 52) + 1 as Week,
RecNo() as MyDim
AutoGenerate 10000;
Tried recreating this and here is what I got:
Measure used:
Dual(
If(Week > 1, ' ',
// Assign the Text here. Example:
Pick(Rank(Year), 'CY', 'PY', '2PY')
),
Count(distinct MyDim)
)
Make sure to set the Number formatting to "Measure Expression":
Here is the data I used:
Data:
NoConcatenate Load
RecNo() as Week
AutoGenerate 52;
Join Load * Inline [
Year
2022
2023
2024
];
Join Load
Floor(Rand() * 3) + 2022 as Year,
Floor(Rand() * 52) + 1 as Week,
RecNo() as MyDim
AutoGenerate 10000;
You can't assign more than one unique text value to a dual dimension, so your if-statement that tries to assign either CY or PY or [blank] to the dual text value is probably what causes your problem.
Thanks both for your support! Actually I don't know what changed but now it works.
Davide
Based on @LRuCelver's answer it seems I was wrong. But different text values in one dual statement can be problematic, see for example https://community.qlik.com/t5/QlikView-App-Dev/Dual-forces-distinct-when-numeric-value-is-same/td-p/...