Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
coloful_architect
Creator II
Creator II

set expression help for showing dimension

I am build a chart table with fields :  customer, Region, Sales_Rep, 2024_Q1 Sales

I only want the table to show customers 's Q1 sales larger than 0, and Q2 sales less or equal to 0.

I am able to build the set expression to pick out the customers but it has to carry all the sales instead of  Q1 sales , see below.

Sum(
{<
customer = {"=Sum({<SaleQuarterYear={'Q1-2024'}>} [Unit Sales]) > 0 and Sum({<SaleQuarterYear={'Q2-2024'}>} [Unit Sales]) <= 0"}
>} [Unit Sales]
)

 

is there a way to make some changes to only show 2024_Q1 Sales ?  wondering if make another layer of set expression at Units Sales measurement would be too much?  I actually tried to do the customer field by using aggr () nest...and units sales for just Q1. I believe the idea is doable ...but somehow my set expression for aggr () for customers do not return what I expect ...maybe I should use Only for the customer display?

 

any ideas?

 

thanks 

 

 

Labels (4)
2 Replies
chriscammers
Partner Ambassador
Partner Ambassador

I think what you need is an intersection of two sets. If you look at Qlik's help page for Set Analysis you will see there are operators that let you combine two sets together and you can use operators to get the intersection, union, exclusion, or symmetric difference. In your case you wan the intersection of customers who have purchased items in different time periods.

So a normal set expression would have angle braces defining the set like this

Sum({<Field1 = {'Val1'},Field2={'Val2'}>}Sales)

you can split those conditions in to two parts and get different results depending on the operator

//Intersection "AND"
Sum({<Field1 = {'Val1'}>*<Field2={'Val2'}>}Sales)

//Union "OR"
Sum({<Field1 = {'Val1'}>+<Field2={'Val2'}>}Sales)

//Exclusion Condition 1 but not condition 2
Sum({<Field1 = {'Val1'}>-<Field2={'Val2'}>}Sales)

//Symmetric Difference, either set but not both
Sum({<Field1 = {'Val1'}>/<Field2={'Val2'}>}Sales)
//Here is an expression I wrote
//Customers with Sales in the Most recent past quarter
//and have bought Electronics
Sum({<CustomerID = {"=Sum({<[OrderDate Relative Quarter] = {'-1'}>}[OrderDetail.DiscountedExtendedAmount])>0"}> *<CustomerID = {"=Sum({<[Product.Category] = {'Electronics'}>}[OrderDetail.DiscountedExtendedAmount])>0"}>}[OrderDetail.DiscountedExtendedAmount])

 

zacsyuan
Contributor II
Contributor II

u r almost there.

 

just add one more component of modifier

 

try this 

 

Sum(
{<
customer = {"=Sum({<SaleQuarterYear={'Q1-2024'}>} [Unit Sales]) > 0 and Sum({<SaleQuarterYear={'Q2-2024'}>} [Unit Sales]) <= 0"}, SaleQuarterYear={'Q1-2024'}
>} [Unit Sales]
)