Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

anil2185
New Contributor III

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.


Thanks in advance.


Regards,

Anil

3 Replies
MVP
MVP

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

Also check here...

http://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/ChartFunctions/NestedAggr...

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...

MVP
MVP

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....

Community Browser