5 Replies Latest reply: Aug 11, 2017 11:33 AM by Sunny Talwar

# Is it possible and how to use arithmetic operations over selected values and set result of these operations as a value in Set Expression?

Have same weekly data and task to make a report for previous week relative to selected one.

Get data for selected week is easy task:

Sum({\$<[WeekStartDate] = \$([WeekStartDate])>}

// some complicated calculation here

)

For previous week hoped following code will do but failed:

Sum({\$<[WeekStartDate]={"\$(=(Num([WeekStartDate])))-7"}>}

// some complicated calculation here

)

I'm relatively new to Qlik Sense, so will be grateful for any help.

• ###### Re: Is it possible and how to use arithmetic operations over selected values and set result of these operations as a value in Set Expression?

May be try this

Sum({\$<[WeekStartDate] = {"\$(=Date([WeekStartDate]-7, 'DateFieldFormatHere'))"}>}

// some complicated calculation here

)

Replace the DateFieldFormatHere with the format for WeekStartDate Field. Also, read here

Dates in Set Analysis

• ###### Re: Is it possible and how to use arithmetic operations over selected values and set result of these operations as a value in Set Expression?

Checked that:
As a WeekStartDate I have for example value 42912.

And it works great with other data fields calculations, but not with user selection.

• ###### Re: Is it possible and how to use arithmetic operations over selected values and set result of these operations as a value in Set Expression?

What selections are making? Do you need a max function if there are more than one date?

Sum({\$<[WeekStartDate] = {"\$(=Date(Max([WeekStartDate])-7, 'DateFieldFormatHere'))"}>}

// some complicated calculation here

)

• ###### Re: Is it possible and how to use arithmetic operations over selected values and set result of these operations as a value in Set Expression?

It is/will be selection of one week, therefore one date. Not an issue.

• ###### Re: Is it possible and how to use arithmetic operations over selected values and set result of these operations as a value in Set Expression?

Difficult to know what might be wrong without taking a look