Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set analysis

I need sum totals in two columns according type.

But I just want to show customers with any sales in type 1, Excluding customer sales of type 0.

I have one colum with: sum({<OrderTypeId={1}>}Total)

another colum with: sum({<OrderTypeId={0}>}Total)

Sample Data Table

Captura.JPG.jpg

Sample wrong graphic

Captura2.JPG.jpg

sample correct graphics (simulated)

captura3.JPG.jpg

This is my sample load

Orders:

LOAD * INLINE [

    CustormerID, OrderTypeId, Total

    1, 0,255

    2, 1,343

    3, 0,213

    4, 1,522

    4, 1,128

  4, 0,228   

    5, 1,123

    5, 0,600

  6, 1,956

];

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

You can use the following in your expression for type 0:

sum({$<CustormerID = {"=sum({$<OrderTypeId = {1}>} Total)>0"}, OrderTypeId={0}>}Total)


or this with aggregation (but i think it will use more resources):

sum(aggr(
if(
sum({<OrderTypeId={1}>}Total) > 0,
sum({<OrderTypeId={0}>}Total), 0)
, CustormerID))

Hope it helps

View solution in original post

2 Replies
Not applicable
Author

Hi,

You can use the following in your expression for type 0:

sum({$<CustormerID = {"=sum({$<OrderTypeId = {1}>} Total)>0"}, OrderTypeId={0}>}Total)


or this with aggregation (but i think it will use more resources):

sum(aggr(
if(
sum({<OrderTypeId={1}>}Total) > 0,
sum({<OrderTypeId={0}>}Total), 0)
, CustormerID))

Hope it helps

Gysbert_Wassenaar

Type 1: sum({<OrderTypeId={1}>}Total)

Type 0: sum({<OrderTypeId={0},CustormerID=p({<OrderTypeId={1}>}CustormerID)>}Total)


talk is cheap, supply exceeds demand