Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

arvindjha2050
New Contributor II

Dynamic Variables

Hello,

I would like to create a variable with varying conditions depending on the month of the quarter, i have used below formulae for the same in Data Load editor:

if Mod(Month(Today()),3)=0 then

Set vTest = Sum({$<[Projection.Period]={'$(=Max([Projection.Period],2))'}>} [Projection.Projection]) ;

elseif Mod(Month(Today()),3)=1 then

Set vTest = Sum([Projection.Projection]);

else

Set vTest = Sum({$<[Projection.Period]={'$(=Max([Projection.Period]))'}>} [Projection.Projection) ;

end if;

I have used these variables in application but it's not working except for the part where set analysis is not there

Why set analysis cannot be computed in if statement?

Thanks,

Arvind

Tags (1)
8 Replies

Re: Dynamic Variables

Try this

if Mod(Month(Today()),3)=0 then

Set vTest = Sum({@<[Projection.Period]={'@(=Max([Projection.Period],2))'}>} [Projection.Projection]) ;

elseif Mod(Month(Today()),3)=1 then

Set vTest = Sum([Projection.Projection]);

else

Set vTest = Sum({@<[Projection.Period]={'@(=Max([Projection.Period]))'}>} [Projection.Projection) ;

end if;

SET vTestFinal = "=Replace($(vTest), '@', '$')";

agigliotti
Honored Contributor II

Re: Dynamic Variables

give a try with the below syntax:

LET vTest = 'Sum( {< [Projection.Period]={' & chr(39) & chr(36) & '(=Max([Projection.Period])) ' & chr(39) & '} >} [Projection.Projection])';

arvindjha2050
New Contributor II

Re: Dynamic Variables

This is not working.

Set analysis works while creating a measure and giving it a formula.

But i want this measure to have a dynamic value using set analysis.

arvindjha2050
New Contributor II

Re: Dynamic Variables

This is not working.

Set analysis works while creating a measure and giving it a formula.

But i want this measure to have a dynamic value using set analysis.

agigliotti
Honored Contributor II

Re: Dynamic Variables

what is not working?

could you share a sample qvf?

arvindjha2050
New Contributor II

Re: Dynamic Variables

Can you help on how to upload sample file as there are only image and video upload options.

agigliotti
Honored Contributor II

Re: Dynamic Variables

try searching for advanced editor option somewhere...i already did it so I can't see that option anymore...

Re: Dynamic Variables

May be try the approach which Stefan talks about here

Expression as a variable with $-sign expansion

Community Browser