Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

beck_bakytbek
Valued Contributor III

compare the variables

Hi Folks,

i got a situation, for instance: my data-area does look like:

Project,Type, Turnover, Cost

1, A, 75, 90

2, B, 75, 78

3, C, 36, 35

i created 2 Variables:

Sum({<Typ = {'*'}>}Turnover) and Sum({<Typ = {'*'}>}Turnover) i want to compare 2 Variables, if my Turnover is lower than my Cost, then the Cost need to be taken

expected output is:

Project,     Type,      Turnover,          Cost,   Compare Ratio

1,                A,           75,                90,          90

2,                B,           75,                78,          78

3,                C,           36,                35,          36

--------------------------------------------------------------------------

                                 186                203         204


does any body have any idea ?

Thanks a lot

Beck

1 Solution

Accepted Solutions

Re: compare the variables

This will work on row level... but to get the right total also, you might need to use Sum(Aggr())...

Sum(Aggr(RangeMax($(vTurnover),$(vCost)), Project))

8 Replies
qlik_aparnav
Contributor II

Re: compare the variables

This can be done using if expression also,

if(Turnover>Cost,Turnover,Cost) as new_field.

In case you can use other than variables.

Re: compare the variables

May be this

Sum({<Type = {"*"}>} RangeMax(Turnover, Cost))

beck_bakytbek
Valued Contributor III

Re: compare the variables

Hi Sunny,

thanks a lot for your feedback and help,

This was my first option as well, i want ask you, can i compare this way 2 Variables ?

Thanks a lot

Beck

beck_bakytbek
Valued Contributor III

Re: compare the variables

Hi aparna,

thanks a lot for your feeback, but this the wrong way, if i use 'if then', so my total sum has a deviation in total.

Beck

Re: compare the variables

can i compare this way 2 Variables ?

Not sure I understand what this means?

beck_bakytbek
Valued Contributor III

Re: compare the variables

Sunny : this way: Sum({<Typ = {'*'}>} RangeMax(Turnover,Cost)) is cool.

but i created 2 Variables:

Sum({<Typ = {'*'}>}Turnover) = vTurnover

Sum({<Typ = {'*'}>}Cost) = vCost

Can i compare those variables ? Can i make that so: Sum({<Typ = {'*'}>} RangeMax($(vTurnover),$(vCost))) ?

thanks a lot

Beck

Re: compare the variables

This will work on row level... but to get the right total also, you might need to use Sum(Aggr())...

Sum(Aggr(RangeMax($(vTurnover),$(vCost)), Project))

beck_bakytbek
Valued Contributor III

Re: compare the variables

Thanks a lot Sunny for your help and feedback.

it does work

Community Browser