Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
jwheatonumich
Contributor II
Contributor II

Using set analysis aggregated by another field

I have three fields in my dataset:

  • Customer
  • SaleID
  • Revenue

I want to create an table with Revenue as an expression and SalesID for a dimension. I only want the table to display rows for sales where a customer's total Revenue is not equal to zero.

My initial attempt led me to the following:

=sum({$<Revenue-={'0'}>}Revenue)

The issue with the above formula is that it checks whether a SalesID has zero revenue, rather than checking whether a Customer does.

Is it possible to aggregate the set analysis by Customer? Or to achieve what I want some other way?

1 Solution

Accepted Solutions
jwheatonumich
Contributor II
Contributor II
Author

I ended up solving the problem by doing the following:

Loading a new table with a flag for Customers with nonzero revenue:

Customer_Revenue_Flag:

LOAD Customer,

if(Revenue <>0,1,0) as Customer_Revenue_Flag

From [...] (qvd);

The new table was joined to my original table by the customer field since they shared a name, allowing me to use the following set analysis to only include customers with nonzero revenue:

=sum({$<Customer_Revenue_Flag-={'0'}>}Revenue)

View solution in original post

6 Replies
Anil_Babu_Samineni

May be this?

=sum({$<Revenue-={"=Customer = 0"}>}Revenue)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

May be try this

=Sum({$<Customer = {"=Sum(Revenue) <> 0"}>} Revenue)

jwheatonumich
Contributor II
Contributor II
Author

This results in a value of zero for revenue on every row.

sunny_talwar

Would you be able to share a sample where you have this problem?

jwheatonumich
Contributor II
Contributor II
Author

This does not filter out any of the results.

It looks like this is filtering out any results where Customer is equal to zero, rather than where Revenue by Customer is zero.

jwheatonumich
Contributor II
Contributor II
Author

I ended up solving the problem by doing the following:

Loading a new table with a flag for Customers with nonzero revenue:

Customer_Revenue_Flag:

LOAD Customer,

if(Revenue <>0,1,0) as Customer_Revenue_Flag

From [...] (qvd);

The new table was joined to my original table by the customer field since they shared a name, allowing me to use the following set analysis to only include customers with nonzero revenue:

=sum({$<Customer_Revenue_Flag-={'0'}>}Revenue)