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: 
Defo
Contributor III
Contributor III

Set specific data label for the first value of some time series

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?

Defo_2-1706698659610.png

Thanks!
Davide

Labels (1)
1 Solution

Accepted Solutions
LRuCelver
Partner - Creator III
Partner - Creator III

Tried recreating this and here is what I got:

LRuCelver_0-1706707784569.png

 

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":

LRuCelver_1-1706707891870.png

 

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;

View solution in original post

4 Replies
LRuCelver
Partner - Creator III
Partner - Creator III

Tried recreating this and here is what I got:

LRuCelver_0-1706707784569.png

 

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":

LRuCelver_1-1706707891870.png

 

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;
henrikalmen
Specialist II
Specialist II

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.

Defo
Contributor III
Contributor III
Author

Thanks both for your support! Actually I don't know what changed but now it works.

Davide

henrikalmen
Specialist II
Specialist II

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/...