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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
AllwynJ
Partner - Contributor II
Partner - Contributor II

Get total of Positive values of a row in a pivot table

Hi Devs,

I have created a pivot table as below.(The first 8 columns)

IDCALABCDEGRAND TOTAL TP(Positive)
10000119-Jan500-200100200-100500 500
 19-Feb0-216000-216 0
 19-Mar16900-50001640 1690

I want to calculate the TP(positive) column. It is the sum of the positive values in the neighboring columns. But if there is a value like 200 and another like -200, which is directly nullifying the value, I don't need to consider that positive value.

ex: in the first row, there is -200 and 200, -100 and 100, 500. So, here the TP value is 500 as 200 and 100 are not considered.

In the second row there are no positives ,so 0.

And in the third row  , there are no negative values for 1690, so the TP is 1690.

(Columns A,B,C,D,E are separate measures calculated based on 'Type' ).Ex:(Sum({<Type={'A'}>}Values))

PFA data file and QVF.

Labels (2)
2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Use an expression of the form:

RangeSum(
	RangeMax(0, A),
	RangeMax(0, B),
	RangeMax(0, C), 
	RangeMax(0, D), 
	RangeMax(0, E)
)

If necessary, substitute A with Sum({<Type={'A'}>}Values). etc. You can nest Sum() inside RangeSum(). Alternatively, simply add the RangeMax() terms.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
AllwynJ
Partner - Contributor II
Partner - Contributor II
Author

Hi @jonathandienst ,

The above code still returns 800 in the first row. It should return 500.