Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
edemerdjieva
Partner - Creator
Partner - Creator

KPI sum problem

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 IDReceipt IDItem IDSales Gross AmountSales Net AmountDiscountAction ID
1A11113.908.90--
1A20110.908.20--
1A20110.908.20--
1A1518.006.00--
1A111--5.00XY
1A201--2.70XY
1A201--2.70XY
1A151--2.00XY

The resulting chart has to be like this:

Action IDTotal SalesTotal Discount
XY31.3012.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

12 Replies
YoussefBelloum
Champion
Champion

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
Partner - Creator
Partner - Creator
Author

Hi Youssef,

None of these work. I added some details in the description to help the understanding of the underlying structure.

Any idea ?

tresesco
MVP
MVP

Try putting NODISTINCT in aggr() like:

=Sum(Aggr(NODISTINCT Sum(TOTAL <[Receipt ID]> [Sales Net Amount]),[Action Id], [Receipt ID]))

YoussefBelloum
Champion
Champion

Did you change the values of the table above ?

teempi
Partner - Creator II
Partner - Creator II

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
Partner - Creator
Partner - Creator
Author

Hi Teemu,

I cannot change the data model, unfortunately. I tried the NODISTINCT qualifier but there is no effect on the Total Sales.

OmarBenSalem

Am I missing sthing?

Capture.PNG

qlik4asif
Creator III
Creator III

Create a chart With

Calculated Diemsion as    =PIck(WildMatch([Action ID],'XY','*-*'),'XY','XY')

Expression 1.  Sum([Sales Net Amount])

                  2.    Sum(Discount)

1213.PNG

teempi
Partner - Creator II
Partner - Creator II

Hi,

What if there are multiple different actions? I'm assuming it's possible.

-Teemu