Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
 edemerdjieva
		
			edemerdjieva
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hello all,
I have a chart displaying marketing action performance based on two KPI : total of sales and total of discounts.
The Fact table has the following fields:
| Store ID | Receipt ID | Item ID | Sales Gross Amount | Sales Net Amount | Discount | Action ID | 
|---|---|---|---|---|---|---|
| 1 | A | 111 | 13.90 | 8.90 | - | - | 
| 1 | A | 201 | 10.90 | 8.20 | - | - | 
| 1 | A | 201 | 10.90 | 8.20 | - | - | 
| 1 | A | 151 | 8.00 | 6.00 | - | - | 
| 1 | A | 111 | - | - | 5.00 | XY | 
| 1 | A | 201 | - | - | 2.70 | XY | 
| 1 | A | 201 | - | - | 2.70 | XY | 
| 1 | A | 151 | - | - | 2.00 | XY | 
The resulting chart has to be like this:
| Action ID | Total Sales | Total Discount | 
|---|---|---|
| XY | 31.30 | 12.40 | 
The problem is with the Total Sales Net Amount, defined as follows:
=Sum(Aggr(Sum(TOTAL <[Receipt ID]> [Sales Net Amount]),[Action Id], [Receipt ID]))
it takes into account distinct items. So in the example above the result is : 23.10 which is not correct. The good value should be 31.30.
Any idea how to write the expression?
Ce message a été modifié par : Elina Demerdjieva
 YoussefBelloum
		
			YoussefBelloum
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi,
try with this:
=sum(aggr(sum([Sales Net Amount]),[Marketing Action ID],[Receipt ID]))
or with this:
=sum(total <[Receipt ID],[Marketing Action ID]> [Sales Net Amount])
 
					
				
		
 edemerdjieva
		
			edemerdjieva
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi Youssef,
None of these work. I added some details in the description to help the understanding of the underlying structure.
Any idea ?
 tresesco
		
			tresesco
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Try putting NODISTINCT in aggr() like:
=Sum(Aggr(NODISTINCT Sum(TOTAL <[Receipt ID]> [Sales Net Amount]),[Action Id], [Receipt ID]))
 YoussefBelloum
		
			YoussefBelloum
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Did you change the values of the table above ?
 teempi
		
			teempi
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi,
Based on the data you provided, I would probably try to separate the discounts into a new table and link them to sales by store id, receipt id and item id (use autonumber or any other method to create composite key). This way each action id should link properly to the sales rows.
Then you should be able to get rid the aggr-expression and just use a normal sum. Seems much easier.
-Teemu
 
					
				
		
 edemerdjieva
		
			edemerdjieva
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi Teemu,
I cannot change the data model, unfortunately. I tried the NODISTINCT qualifier but there is no effect on the Total Sales.
 OmarBenSalem
		
			OmarBenSalem
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Am I missing sthing?
 qlik4asif
		
			qlik4asif
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Create a chart With
Calculated Diemsion as =PIck(WildMatch([Action ID],'XY','*-*'),'XY','XY')
Expression 1. Sum([Sales Net Amount])
2. Sum(Discount)
 teempi
		
			teempi
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi,
What if there are multiple different actions? I'm assuming it's possible.
-Teemu
