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: 
Brysonds
Contributor III
Contributor III

Aggr Sum question

Hello,

I have a simple data set:

Brysonds_0-1679078738211.png

 

In a Pivot table, I am showing cases where the sell price increased month over month with a 1 and if they went down with a -1 by using the following formula:

If(Sum([Sell Price]) - Before(Sum([Sell Price])) <0, -1,
If(Sum([Sell Price]) - Before(Sum([Sell Price])) >0, 1, 0))

Brysonds_1-1679078851285.png

 

However, I wish to show the total number for the company (i.e. February should show 2 not 1 as the total).

I tried several combinations of Aggr functions, but none of them returns any values. Example below -- any advice?

Aggr(
Sum(
If(Sum([Sell Price]) - Before(Sum([Sell Price])) <0, -1,
If(Sum([Sell Price]) - Before(Sum([Sell Price])) >0, 1, 0))
)
, Company, Product, Month
)

They either return nulls or 0s in the pivot table depending on the order and if it is before/after the if statements.

 

Labels (2)
2 Replies
brunobertels
Master
Master

May be this

 

sum(aggr(

rangesum(above(

Sum(
If(Sum([Sell Price]) - Before(Sum([Sell Price])) <0, -1,
If(Sum([Sell Price]) - Before(Sum([Sell Price])) >0, 1, 0))
)

,0, rowno()))

,Company, Product, Month ))

 

Brysonds
Contributor III
Contributor III
Author

Hi Bruno, thanks for trying to help. Unfortunately, this just results in the table returning 0 for all rows/columns.