Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

Sum elements from 2 different fields depending on a condition

Hi,

I have this flat table in my app in Qliksense: 

ProductsPriceCost
A56
B75
C42
D810

What I want is to have a single expression that can sum the larger of Cost or Price for all Products (essentially summing all the bold cell).

I was thinking of creating like a dummy table using aggr that produce something like this:

Productsmax(Price,Cost)
A6
B7
C4
D10

and just simply sum the Max(Price,Cost) field. But I haven't really come up with anything yet.

Please let me know if this is the right way or there is a better approach. Thanks!

1 Solution

Accepted Solutions
aarkay29
Valued Contributor

Re: Sum elements from 2 different fields depending on a condition

Try This

RangeMax(Price,Cost)

2 Replies
aarkay29
Valued Contributor

Re: Sum elements from 2 different fields depending on a condition

Try This

RangeMax(Price,Cost)

Not applicable

Re: Sum elements from 2 different fields depending on a condition

Thanks! I managed to use that in my data load editor as:

LOAD

...

RangeMax(Price,Cost) as MaxPC

...

And I just need to sum the MaxPC field as usual within the app. It works perfectly this way.