Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
lmengesha
Partner - Contributor III
Partner - Contributor III

Variable call in Set Analysis not working

I have the following Set expression within one of the dimensions of a straight table:

Sum({$<$(vSetPreviousNMonth(0))>} [# Departures Performed])

where vSetPreviousNMonth has the following definition:


PeriodID = {$(=Max(PeriodID) – $1)}, Year = , Quarter = , Month = , Period =


leaving $1 to insert parameters and output something else, the problem is that this does not work and the script syntax highlighting

displays it as an error. Is this expression written properly or is there a specific reason this does not work?

PS: I'm relatively new to Set analysis and Qlikview overall

7 Replies
arvind_patil
Partner - Specialist III
Partner - Specialist III

HI Leonardo,

May be this will work for you:

Sum({<$(vSetPreviousNMonth)>} [# Departures Performed])


=Sum({<$(vData)>}Value)(this work For Me)


Thanks,

Arvind Patil

lmengesha
Partner - Contributor III
Partner - Contributor III
Author

I tried with an = at the beginning but it did not work.

effinty2112
Master
Master

Hi Leonardo,

sometimes the script editor tells you there's an error in set analysis when there isn't. Try your expression vSetPreviousNMonth with various values written in place of the $1 parameter as a way to test. To my eyes your expression looks okay.


good luck


Andrew

ahaahaaha
Partner - Master
Partner - Master

Hi,

May be like this

Expression:

Sum({<$(vSetPreviousNMonth)>} [# Departures Performed]) or

Sum({<$(#vSetPreviousNMonth)>} [# Departures Performed])

vSetPreviousNMonth :

PeriodID = {"$(=Max(PeriodID))"}, Year = , Quarter = , Month = , Period =

sunny_talwar

When you say it doesn't work, does it not give you any solution or is it just showing a null?? Would you be able to share  a sample to take a look at this?

stigchel
Partner - Master
Partner - Master

I see no added value in using the variable with parameter as opposed to using it directly in the expression. The various $ expansions and the moments that they are evaluated make it very tricky. Directly in the expression:

Sum({$<PeriodID = {"$(=Max(PeriodID )-0)"},Year=,Quarter=,Month=,Period=>} [# Departures Performed])

Edited:Bold parts

lmengesha
Partner - Contributor III
Partner - Contributor III
Author

Sorry guys this was an error on my part, the Set expression was working but the relationship between the Master Calendar and the Fact Table within the data model was non-existent, therefore the calculations returned 0 at every turn, although I do appreciate the answers provided, I had to look at the data model for a good 30m to figure this out (The answer was to create a primary key between both tables from common fields in both tables), thanks for the help non the less.