Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
edemerdjieva
Partner - Creator
Partner - Creator

KPI based on Aggr() function

Hello all,

I have a pivot chart to display number of sales and number of returns of items by business unit, store, and by return reason. One item can be associated with several return reasons.

There are two KPI in the chart: 1) number of item returns and 2) number of item sales. I use Aggr() function to calculate item sales. Below is an example of the chart:

Business unitStoreItemReturn reasonNb salesNb returns
100719ABroken231
Change for another item231
Wrong size231
10083AWrong size153
Broken152

The "Nb sales" has to be a total per item. Return reason should not be taken into account in this case.

If item A was sold 23 times in store 719 and returned 3 times then '23' should be displayed on each line (as the example above).


Here is the expression for 'Nb sales':


Sum(Aggr(Sum([Quantity sold]),[Store],[Item]))


The only problem is that value '23' is displayed only one time (on one of the return reason lines). How can it be repeated on each return reason line ?


Thank you in advance,

Elina

1 Solution

Accepted Solutions
edemerdjieva
Partner - Creator
Partner - Creator
Author

Ok, now it worked. I had to add all dimensions in the chart to the TOTAL qualifier.

Here is the final expression:

Sum(TOTAL <[Business Unit], Store, Item> Aggr(Sum([Quantity sold]),[Business Unit], [Store], [Item]))


Thanks for the help!

View solution in original post

8 Replies
MK_QSL
MVP
MVP

Try


Sum(Total <Item,Store> [Quantity sold])

MK_QSL
MVP
MVP

or use

Sum(Aggr(NoDistinct Sum([Quantity sold]),[Store],[Item]))

edemerdjieva
Partner - Creator
Partner - Creator
Author

Doesn't working. NODISTINCT doubles the result

oussema_laribi
Contributor II
Contributor II

Try This :

Sum(Total <"business unit" ,Store,Item> [Quantity sold])

MK_QSL
MVP
MVP

have you tried my 1st answer?

Yeah.. add Business Unit also in Total Qualifier

Sum(Total <Item,Store, [Business Unit]> [Quantity sold])

Sum(Aggr(NoDistinct Sum([Quantity sold]),[Store],[Item],[Business Unit]))


Check spelling of all fields

edemerdjieva
Partner - Creator
Partner - Creator
Author

It would work if the dimension 'return reason' wasn't included in the chart.

Without the Aggr() function the expression is always = 0.

edemerdjieva
Partner - Creator
Partner - Creator
Author

Ok, now it worked. I had to add all dimensions in the chart to the TOTAL qualifier.

Here is the final expression:

Sum(TOTAL <[Business Unit], Store, Item> Aggr(Sum([Quantity sold]),[Business Unit], [Store], [Item]))


Thanks for the help!

MK_QSL
MVP
MVP

Glad that you got your output.

Sum(Aggr(TOTAL <[Business Unit], Store, Item> Sum([Quantity sold]),[Business Unit], [Store], [Item]))


Have you tried this?