5 Replies Latest reply: Oct 2, 2013 10:41 AM by Fredrik Wikberg

# 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

• ###### Re: Set Expression with Variable minus one

change to \$(vCurentYear)-1 within your expression

• ###### Re: Set Expression with Variable minus one

Hi,

Try this

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

Hope this helps you.

Regards,

Jagan.

• ###### Re: Set Expression with Variable minus one

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

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

Jonathan

• ###### Re: Set Expression with Variable minus one

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

• ###### Re: Set Expression with Variable minus one

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.