
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Subtract from a variable
New to set analysis...
I my set analysis expression works but I am trying to add one more piece: IncurredMonth={'=$((vMaxMonth)-1)'}
It then takes my results to "0". all I want is to take the variable "vMaxMonth" and subtract one from it but somhow my syntax must be off.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello
Since you create the variable (tools / variable overview) can be defined as -1 and no need to put quotes. example:
VarMesAnt = Month (num (if ((month-1) = 0.12, week-1)
, '#, # # 0', '.' , ','))
regards

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try double-quotes instead of the singles.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello
Since you create the variable (tools / variable overview) can be defined as -1 and no need to put quotes. example:
VarMesAnt = Month (num (if ((month-1) = 0.12, week-1)
, '#, # # 0', '.' , ','))
regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nothing seems to have an effect:
If I do just:
sum({<[IncurredYear]={$(vMaxYear)},[IncurredMonth]=,[AMOUNT_TYPE]={'ACTUAL'}}>}[Ending_Balance_CNT])
it returns the same is if I add the extra criteria:
sum({<[IncurredYear]={$(vMaxYear)},[IncurredMonth]=,[AMOUNT_TYPE]={'ACTUAL'},[IncurredMonthNum]={"=vMaxMonth1"}>}[Ending_Balance_CNT])
The expression is pretty much ignoring: [IncurredMonthNum]={"=vMaxMonth1"} so I must be writing it wrong.
vMaxMonth1 is a variable that is = to 3.

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you post your app?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
sum({<[IncurredYear]={$(vMaxYear)},[IncurredMonth]=,[AMOUNT_TYPE]={'ACTUAL'},
[IncuredMonth= {$(=vMaxMonth -1)}>}[Ending_Balance_CNT])
try in this way ...
if not try to calculate or get the month-1 value into other variable and pass that variable into Incurred Month.
Regards,
Shiva


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It should be IncurredMonth={'$(=$(vMaxMonth)-1)'}
$(= ...) instructs Qlikview to evaluate the expression inside the brackets and $(vMaxMonth)-1 is the expression to be evaluated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Shiva - thanks a ton! That worked.
Steve

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Masha..
Based on what you said:
"It should be IncurredMonth={'$(=$(vMaxMonth)-1)'}
$(= ...) instructs Qlikview to evaluate the expression inside the brackets and $(vMaxMonth)-1 is the expression to be evaluated."
why in my expression which now works
does [IncurredYear]={$(vMaxYear)} not have an "= "before the variable vMaxYear
but
[IncurredMonth= {$(=vMaxMonth -1)} does have an "=" before the variable vMaxMonth -1
Whole expression:
sum({<[IncurredYear]={$(vMaxYear)},[IncurredMonth]=,[AMOUNT_TYPE]={'ACTUAL'},
[IncurredMonth= {$(=vMaxMonth -1)}>}[Ending_Balance_CNT])


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Equal sign (=) is needed when there is an expression to be evaluated, e.g $(=vMaxMonth -1).
When there is just a variable that is to be replaced with its value, e.g. $(vMaxMonth), no = sign is needed.
The difference between my example and Shiva's is that Shiva is using a variable in the expression, while I'm using the value of the variable.
