Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
carolin01
Partner - Creator II
Partner - Creator II

Sum-Formular with Variable & where statement

Hi,

could anybody help me to create this formular correctly:

If($(vCurrency)='EUR', sum (<FYear=($(vPreviousYear)>NettAmountEUR), If($(vCurrency)='USD', sum (<FYear=($(vPreviousYear)>NettAmountUSD), Sum(<FYear=($(vPreviousYear)>NettAmountJPY))), where OrderPhaseDesc = 'Bookings'

I would like to see the sum of the OrderPhaseDesc "Bookings" relying on the variable vCurrency either as EUR, USD or JPY for the previous year.

The variable for the previous year is: only(year(today())-1) . The variable vCurrency can just either indicate EUR, USD or JPY.

Many thanks in advance!

Carolin

1 Solution

Accepted Solutions
swuehl
MVP
MVP

NettAmountEUR is the correct field name, right?

So I think this is working correctly.

You still have an issue using the vPreviousYear variable, define the variable in variable overview with a leading equal sign

=only(year(today())-1)

edit: please have a look into

http://community.qlik.com/blogs/qlikviewdesignblog/2013/11/04/the-magic-of-variables

View solution in original post

6 Replies
swuehl
MVP
MVP

Maybe like this:

=sum({<FYear = {$(vPreviousYear)}, OrderPhaseDesc = {Bookings} >} NetAmount$(vCurrency) )

carolin01
Partner - Creator II
Partner - Creator II
Author

That is much shorter and very close. It does not concatenate the NettAmount with the vCurrency formular.

sum({$<FYear = {$(vPreviousYear)}, OrderPhase_Desc = {Bookings}>}NettAmount{$(vCurrency)})

swuehl
MVP
MVP

I don't think you should use curly brackets with the currency dollar sign expansion.

sum({$<FYear = {$(vPreviousYear)}, OrderPhase_Desc = {Bookings}>}NettAmount$(vCurrency) )

should be enough if the vCurrency variable does not introduce e.g. leading spaces.

If you use above as expression in e.g. a straight table with no expression label, then hovering over he expression label cell, what do you see?

carolin01
Partner - Creator II
Partner - Creator II
Author

It shows the following:

straight table.png

But the value is zero... 😉

swuehl
MVP
MVP

NettAmountEUR is the correct field name, right?

So I think this is working correctly.

You still have an issue using the vPreviousYear variable, define the variable in variable overview with a leading equal sign

=only(year(today())-1)

edit: please have a look into

http://community.qlik.com/blogs/qlikviewdesignblog/2013/11/04/the-magic-of-variables

carolin01
Partner - Creator II
Partner - Creator II
Author


"

You still have an issue using the vPreviousYear variable, define the variable in variable overview with a leading equal sign

=only(year(today())-1)"

This was the solution!!!

Thank you