Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
LOAD * Inline [
PRODUCT, YEAR, values
A, 2017, 10
B, 2017, 15
A, 2016, 5
B, 2016, 8
];
Set vMaxYear = max(YEAR);
Let vSum = Replace( 'sum({<YEAR ={@($(vMaxYear))} >} values)', '@', Chr(36));
In my expression, $(vSum) outouts 0.
I've tried the following but non-seem to work using Qlik Sense.
Set vMaxYear = max(YEAR);
Let vSum = Replace( 'sum({<YEAR ={@($(vMaxYear))} >} values)', '@', Chr(36));
Let vSum2 = Replace( 'sum({<YEAR ={@($(=vMaxYear))} >} values)', '@', Chr(36));
Let vSum3 = Replace( 'sum({<YEAR ={@"($(=vMaxYear))"} >} values)', '@', Chr(36));
Let vSum4 = Replace( 'sum({<YEAR ={@(=vMaxYear)} >} values)', '@', Chr(36));
The first two lines work as it is supposed to work.
What do you mean when you say "I cannot make this work". What do you want to happen?
I added a sample data to make it more clear
I do the same thing like this
Set vMaxYear = max(YEAR);
Set vSum = Sum({<YEAR = {#(=vMaxYear)}>} values);
Let vSum = Replace(vSum, '#', '$');
The advantage by separating the replace() is that I can clearly see what the expression result will be.
I would normally test this by entering these expressions in temporary text boxes to be sure that everything is working as expected
=Sum({<YEAR = {2018}>} values)
=max(YEAR)
=$(vMaxYear)
=vSum
=$(vSum)