3 Replies Latest reply: Mar 27, 2018 8:14 AM by Petter Skjolden

# Need sum of if column

Hi All,

I am struck in a situation where I need to show sum of a column in straight table of Qliksense.

Below is the expression.

if(Above(Total if(column(1)>column(6),

if(MonthName(MonthEndDate) = Monthname(\$(vselectedDate)) , Day(DATE_INVOICE_DATE)

, if(Num(MonthEndDate) < \$(vselectedDate) , Day(MonthEndDate))),

(column(1)-column(6))/column(2)

))<0,0,

if(column(1)>column(6),

if(MonthName(MonthEndDate) = Monthname(\$(vselectedDate)) , Day(DATE_INVOICE_DATE)

, if(Num(MonthEndDate) < \$(vselectedDate) , Day(MonthEndDate))),

Fabs((column(1)-column(6))/column(2))

))

Output of this statement is:-

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

-

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

21

28

3.3

0

I want the sum of these lines at top.

Regards,

Anil

• ###### Re: Need sum of if column

Aggr() function could be of help to you in this situation - I think it would have to look like this:

Sum(Aggr(

Sum( .....your-expression-from-above... ) ,

Dim1, Dim2, .....

))

• ###### Re: Need sum of if column

Sunny's response reminds me that you will have to replace all the Column(...) references with the actual expressions behind each of them into you expression before you wrap it into an Aggr() like I suggested. That might mean that you will get quite a large expression....

• ###### Re: Need sum of if column

Also check here...

http://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/ChartFunctions/NestedAggregations/sum-of-rows…

but once you use this, you will not be able to use column() function... you will either have to use the actual expression or you can use variables...