Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
anil2185
Contributor III
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
petter
Partner - Champion III
Partner - Champion III

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

))

sunny_talwar

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

petter
Partner - Champion III
Partner - Champion III

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