Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
sowmi
Creator
Creator

Total in Pivot qliksense

Hello all,

I am using pivot table based on calculations ,i have negative values ,so i need to replace negative values with zero,So i did within pivot table and showing zero for negative values ,And additionally  i need to display total so what i am facing is In TOTAL'S ,it is summing up negative values instead of "Zero",

For example :  O/p from pivot   expecting o/p

                             -1                              0

                             -2                              0

                               1                              1

                             2                                 2 

Total :                0                                 3

 Can Someone Help

Thanks                                          

Labels (2)
19 Replies
rubenmarin

Hi, Rangemax funtion returns the higher on any value, so you if your expression is Sum(Sales) you can use RangeMax(0, Sum(Sales)), but this won't work for totals, to make this work for totals you can add an aggr so the total sums each row indiviually:

Sum(Aggr(RangeMax(0, Sum(Sales)), Dimension1, Dimension2...) // Dimension1,Dimension2 are the fields used as dimension in the table.

Another possiblibity is using set analysis, like:

- Sum({<Sales={">=0"}>} Sales)

- Sum({<Customer={"=Sum(Sales)>0"}>} Sales) // Only sums customers with sum of sales higher than 0

 

PrashantSangle

Hi,

 

try below

 

if(sum(Sales)>0,Sum(Sales),0)

 

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
sowmi
Creator
Creator
Author

Hi,
I used IF condition,in table it is replacing negative value with zero ,when I am adding default total in pivot table instead of zero it is summing up both negative and positive values and displaying total Values
Rohan
Specialist
Specialist

Hello,

Instead of handling this in the front end, create a new dimension to ignore the negative values using the above if condition in back-end & then use this new dimension  as a measure. May be that'll help.

Regards,

Rohan.

Kushal_Chawda

@sowmi  only if condition won't work here. You may need to apply aggr function  for total to work it properly.  Try below

sum(aggr(if(sum(Sales)>0,sum(Sales),0),Dimension1, Dimension2))

where Dimension1, Dimension2 are your pivot table dimensions. 

sowmi
Creator
Creator
Author

Hi Kush,

If my calculation sum(Sales) has only positive values then sum(aggr(if(sum(Sales)>0,sum(Sales),0),Dimension1, Dimension2)) doesn't work?

Kushal_Chawda

It should work if you have only positive values 

sowmi
Creator
Creator
Author

I am using valuelist for one of the dimensions,If i use your code i am only getting values for the column for remaining it is showing zero .

sowmi_0-1597092115720.png

 

Kushal_Chawda

What is actual valuelist expression and measure you are using?