Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
bmachado7
Contributor
Contributor

Sum with multiple conditions

Hi everyone,

I'm a new qlik sense user and I've been racking my brain for hours without getting anywhere.

I have a table with sales splitted by product and cities. 

I need to sum sales of all cities where Cluster Special' Products were sold (in the example, I have Product A in special cluster)

So, in the table below, product A was sold in city1 and city3. I need to understand the percentage of total sales these 2 cities represents, regardless of the product.

Once identified the cities , I will sum all sales (regardless of the product or cluster) of them (city1 +city3) and then divide it by total sales to find out how representative they are. 

The problem is that I'm not being able to create a condition that sums the sales of the cities selected regardless of the product. It always considers only sales of special products in the cities. I need it all. Cluster field should only help me to identify which cities I should sum.

One of my many attempts of calculation was:

If(CLUSTER='Special' and Sales>0,
sum({<[ANO]={$(=Max([ANO]))},>}$(=[Sales]))
,0)

CityProductClusterSales
City1ASpecial75
City2ASpecial0
City3ASpecial41
City1BOther23
City2BOther97
City3BOther86
City1COther99
City2COther84
City3COther68
  Total sales573
  City1+City3392
  %represent68,4%

 

Can someone help me, please?

3 Replies
Channa
Specialist III
Specialist III

If(CLUSTER='Special' and Sales>0,
sum({<[ANO]={$(=Max([ANO]))},>}[Sales])
)

/

 

sum({<[ANO]={$(=Max([ANO]))},>}[Sales])

 

Channa
bmachado7
Contributor
Contributor
Author

Tks, Channa

But this syntax only considers sales from cluster special. I was hoping to sum all sales of all products of cities that have sales of special cluster

The cluster information should be used only yo id the cities I have to sum. The sum itself should consider all products sold in the city

marcus_sommer

I think it's only with an indirect set analysis lie p() and e() possible to set the conditions. Take this as a starting point for your task:

sales.JPG

- Marcus