Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
lmengesha
New 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
Valued Contributor III

Re: Variable call in Set Analysis not working

HI Leonardo,

May be this will work for you:

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


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


Thanks,

Arvind Patil

lmengesha
New Contributor III

Re: Variable call in Set Analysis not working

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

effinty2112
Honored Contributor

Re: Variable call in Set Analysis not working

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
Honored Contributor

Re: Variable call in Set Analysis not working

Hi,

May be like this

Expression:

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

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

vSetPreviousNMonth :

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

Re: Variable call in Set Analysis not working

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
Honored Contributor

Re: Variable call in Set Analysis not working

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
New Contributor III

Re: Variable call in Set Analysis not working

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.

Community Browser