Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum, Set Analysis

Hi guys! I need some help.

Please refer to the table below as you answer my questions.

ProductStorePrice
A15.00SUP-1
A15.00SUP-2
A27.00SUP-1
A27.00SUP-2
B110.00SUP-1
B110.00SUP-2
B29.50SUP-1
B29.50SUP-2
C121.00SUP-1
C121.00SUP-2
C219.50SUP-1
C219.50SUP-2

I have a separate Object that shows the Total Price.

Using Set Analysis, how can I output the:

1. Total for a "selected" Product

    For instance, Product A's Total Price is computed as 5.00 (Store 1 price) + 7.00 (Store 2 price) = 12.00

    I only need one price of the product for each store.

2. Total Price of ALL products (if no specific product is selected)

    Bearing in mind the above computation for a certain product, I need to get the Total Price for ALL products.

    Product A (12.00) + Product B (19.50) + Product C (40.50)  = 72.00

Thank you in advance!

1 Solution

Accepted Solutions
Nicole-Smith

You should be able to use the following expression for both:

sum(aggr(only(Price),Store,Product))

If you select a product, it will only show the total for that selected product.  If you don't select a product, it will show the total of all products.

**EDIT:  See attached example.

View solution in original post

5 Replies
Nicole-Smith

You should be able to use the following expression for both:

sum(aggr(only(Price),Store,Product))

If you select a product, it will only show the total for that selected product.  If you don't select a product, it will show the total of all products.

**EDIT:  See attached example.

hic
Former Employee
Former Employee

You don't need set analysis for this. If I understand you correctly, you want one price per distinct combination of Product and store, and you want to average within this group. Hence

     Aggr(Avg(Price),Product,Store)

The Aggr() returns an array of Prices that you then want to sum. Hence your formula is

     Sum(Aggr(Avg(Price),Product,Store))

If you use this in a chart with Product as dimension, the chart will display one value per product (answer to question 1) and the total will be the answer to question 2.

HIC

MK_QSL
MVP
MVP

Try

=SUM(Aggr(sum(Distinct Price),Product,Store))

Nicole-Smith

Henric Cronström's use of avg() inside of the aggr() is probably the best option in case you have different prices for the same product within the same store.

Not applicable
Author

Thank you for all of your help guys!

Happy holidays to you all!