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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
sunitha_chellaiah
Partner - Creator
Partner - Creator

Get Total Based on Condition

Hi I am trying to get sum of  quantity whose value is >2000 and <2000

 

I want  to get sum of last 2 columns. That is total to be  displayed  at the top of the table . Please help to create expression.

brand

ID

QTY

>2000

<2000

QTY (>2000)

QTY (<2000)

HUMIRA

G04A-20005289

271273

1

0

271273

-

HUMIRA

G04A-20015888

4584

1

0

4584

-

HUMIRA

G04A-20016957

2453

1

0

2453

-

HUMIRA

G04A-20021980

29685

1

0

29685

-

HUMIRA

G04A-20014985

-4

0

1

-

-4

HUMIRA

G04A-20059013

751

0

1

-

751

HUMIRA

G04A-20059014

34

0

1

-

34

Labels (1)
3 Replies
MatheusC
Specialist II
Specialist II

Hi,
After your condition, close your expression so that it can give you the sum of the results, perhaps this:

Sum(aggr(Conditional Expression, ID, brand))


- Regards, Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
sunitha_chellaiah
Partner - Creator
Partner - Creator
Author

But conditional expression is like this

sum(aggr(fabs(num($(vActuals_YearToDate),'###0'))>'2000',dfu))*-1

which gives value 1 for each row.

But I want  to calculate sum of qty

MatheusC
Specialist II
Specialist II

This could not be done in the following way using if() or pick(), of course I am assuming the scenario to which I send an example.

sum(aggr(if( Sum(QTY)<2000,Sum(QTY),0),ID,brand))
or 

sum(aggr(if( Sum(QTY)<2000,Sum(QTY),0),ID))

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!