Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Expression with Variable minus one

Hi

I am trying to create a set analysis for an expression that have a variable that I want to take minus 1 with.

I have the following expression in a bar chart that works fine.

=Sum({<Date.Year={$(vCurrentYear)},Date.WeekNum=>} InvoiceTrans.Quantity)

I want to add a line chart to the same chart with the sum for CurrentYear minus 1.

I have written this expression.

=Sum({<Date.Year={$(vCurentYear-1)},Date.WeekNum=>}InvoiceTrans.Quantity)

This does not work due to the connotation in the set expression for year -1.

I couldnt find any helpful info at the website. So I wonder if anyone knows how this set expression should be writte to display data for the graph?

Thanks for any help.

//Fredrik

5 Replies
omyahamburg
Creator II
Creator II

change to $(vCurentYear)-1 within your expression

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

=Sum({<Date.Year={$((=vCurentYear-1))},Date.WeekNum=>}InvoiceTrans.Quantity)

Hope this helps you.

Regards,

Jagan.

Anonymous
Not applicable
Author

Try this.

=Sum({<Date.Year={$(vCurentYear)-1},Date.WeekNum=>}InvoiceTrans.Quantity)

Or create a new variable "vPreviousYear" and set it equal to =max(Year)-1

jonathandienst
Partner - Champion III
Partner - Champion III

Might need to remove the double parentheses and quote the expression:

Sum({<Date.Year = {'$(=vCurentYear-1)'}, Date.WeekNum = >} InvoiceTrans.Quantity)


Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thank you everyone for the input. Actuly non of the answers are working. I thought about adding a new variable at the start but wanted to limit the number of variables I have in the document. So I wanted to create the filter in the set analysis instead. It is for a demo so I will create the new variable for this specifically.

Set analysis is great but I often find that you spend time trying to get the connotation right.