Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Valueloop use incremented values

Hi all,

I'm looking to use ValueLoop, not sure it's the way to go given my expression below.

=IF( ValueLoop(201401,201408,1)=201405, 

sum({<x={Yes} = P ({$<Period={201405},y={Yes}>} Id ) > * <x={Yes} = P ({$<Period={201404},y={yes}>} Id )> } [value1] )

/

sum({<x={Yes} = P ({$<Period={201405},y={Yes}>} Id ) > * <x={Yes} = P ({$<Period={201404},y={yes}>} Id )> } [value2] )

,

if(ValueLoop(201403,201405,1)=201404,

sum({<x={Yes} = P ({$<Period={201404},y={Yes}>} Id ) > * <x={Yes} = P ({$<Period={201403},y={yes}>} Id )> } [value1] )

/

sum({<x={Yes} = P ({$<Period={201404},y={Yes}>} Id ) > * <x={Yes} = P ({$<Period={201403},y={yes}>} Id )> } [value2] )

))

What I'm looking for is to use the values in ValueLoop(201401,201408) so that they can be used dynamically in the set analysis "Period={201405}", "Period={201404}"  e.t.c. In other words be able to use the incremented values instead of hard code it like done above. Does anybody know if its possible to do this ?

Any other suggestions ? Basically I'm looking for to loop through my set and use a counter, I've got way to many conditions and measures that needs to be calculated.


Thanks,

Jonas

3 Replies
JonnyPoole
Employee
Employee

The SET ANALYSIS looks a little strange.. can you share a QVW sample ?

Not applicable
Author

Thanks for the response.

Sorry.. was a bit too fast there, please see attached qvw.

Jonas

JonnyPoole
Employee
Employee

hmm.. i can only get the syntax to work if there is only 1 value in the valueloop. 

Sample SET statement like this:

sum({<x={yes},id = P ({$<Period={'$(=ValueLoop(201405))'},y={yes}>} id ) > * <x={yes}, id = P ({$<Period={'$(=ValueLoop(201405)-1)'},y={yes}>} id ) > }

[value1] )

but it doesn't work if its a true loop with 2+ numbers. Same with valuelist()

maybe you'll get some other suggestions ?