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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rorand
Helper I
Helper I

Calculate sum and share based on a column with repeating values

Hello community!
This is my first post here, hope I do this correctly 🙂

I have a huge table with sales data from my customers.

In this table i have several products, product groups, weeks, customers, etc.

I get one row pr. item/customer/week with my revenue, and the total revenue of the Item Group pr. customer and week.

 

I want to find two things:

1. The total amount of revenue, based on my selection of slicers in my report

2. My share of revenue pr. product 

My problem here is that whenever I have a revenye on my Item, the "Total Item group revenue" shows up, and is therefore repeating itself several times.

 

This is what my table look like, I have only put up one week in this example (mye table contains a lot more columns and rows, but these are the important ones):

WeekCustomerItemItem groupMy revenueRevenue total Item group in store
Week 1NorthProduct AYellow               50           10 000
Week 1NorthProduct BYellow             100           10 000
Week 1NorthProduct CYellow             200           10 000
Week 1NorthProduct DBlue             200            5 000
Week 1NorthProduct EBlue               50            5 000
Week 1SouthProduct AYellow               20            6 000
Week 1SouthProduct BYellow               40            6 000
Week 1SouthProduct CYellow               50            6 000
Week 1SouthProduct DBlue             100            1 000
Week 1SouthProduct EBlue             200            1 000
Week 1EastProduct AYellow             100            1 500
Week 1EastProduct BYellow             150            1 500
Week 1EastProduct CYellow               10            1 500

 

 

Regards
Andreas

9 REPLIES 9
v-juanli-msft
Community Support
Community Support

Hi @rorand

To make values change with slicer, please consider use a measure instead of calculated column.

would you like the following?

Measure =
CALCULATE (
    SUM ( Sheet2[My revenue] ),
    FILTER (
        ALLSELECTED ( Sheet2 ),
        [Item group] = MAX ( [Item group] )
            && [Customer] = MAX ( [Customer] )
    )
)

If you select week1, the measure will calculate the total revenue per  Customer for different Item group in week1.
7.png

 

If your requirement is not like this, please show an example for better analysis.

 

Best Regards

Maggie

 

Hello again.
Thank you for your replies @Ashish_Mathur and @v-juanli-msft .

I tried your suggestions but still could'nt find a way to solve my problem.
Therefore I have'nt looked at this for some time, but now I am trying to fix this again.

 

So, I will try to make you better understand what I am trying to fix.

 

Data
Here is a Dropbox-link to an Excel-sheet with an edited sample of my data.

 

A short explanation of the two right-most colums in the sheet:

Revenue: shows the revenue for the product at the store for that specific date

Total revenue for Product Group in store:  shows the revenue for the whole product group at the store for that specific date (not only my products, but also my competitors products that are in the same product group.

 

What I am trying to calculate:

1. The sum of Total revenue for Product Group in store

2. My revenues %-share of Total revenue for Product Group in store

 

So the problem that I am having trouble with is that I have a lot of products that are in the same category, and therefore the Total revenue for Product Group in store will repeat itself per item that are in the same product group for one store and one specific day.

It is easier to understand if you take a look at my Dropbox-file.

 

In my original data I also have postal-codes, region and store-chain for each customer, so I also want to be able to aggregate the two measures up and down as i like with filters on postal codes, region, store-chain, product group an product.

To say it easy I want theese measures to work for a single product for each store, and also for all the different levels - both on the customer- and product-side of my data.

 

Hope this will make you understand better what my problem is, and can help me find a solution 🙂

 

Best regards

Andreas

Hi,

On the file that you have shared, please show the exact result which you are expecting.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

 

Hello @Ashish_Mathur and thank for your reply.

 

I have added a Picture-sheet in the Excel-book showing a couple of the visuals I am trying to get.

Also, HERE is a .pbix-file, but this is for now showing the same as in the picture 🙂

 

Best regards

Andreas

Hi,

I do not understand your requirement.  Share a simple dataset and show the exact expected result in a simple Table format.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hello again @Ashish_Mathur.

 

Sorry for my bad explanation and thank you for your patience.

 

This is what I have and what I am expexting to get, with customer 442 as an example, the two rightmost columns are showing my expected results.

As you can see, it is in the Totals I am having problems:
Red colour = wrong totals

Green colour = correct totals

This is because the total for the Product Group Category is already defined per line on each product.

 

DateCustomer NameProduct GroupProduct NameRevenueTotal revenue for Product Group in storeMy ShareExact expected result of Total revenue for Product Group in storeExact expected result of My Share
17.03.2020Customer 442Product Group 1Product Name 1374956241 %56241 %
17.03.2020Customer 442Product Group 1Product Name 1405556241 %56241 %
17.03.2020Customer 442Product Group 1Product Name 1761656240 %56240 %
17.03.2020Customer 442Product Group 1Product Name 1783456241 %56241 %
17.03.2020Customer 442Product Group 1Product Name 2052156240 %56240 %
17.03.2020Customer 442Product Group 1Product Name 62156240 %56240 %
17.03.2020Customer 442Product Group 1Total195337431 %56243 %
17.03.2020Customer 442Product Group 2Product Name 4138002291460 %2291460 %
17.03.2020Customer 442Product Group 2Product Name 80167229141 %229141 %
17.03.2020Customer 442Product Group 2Product Name 82229229141 %229141 %
17.03.2020Customer 442Product Group 2Product Name 9622229140 %229140 %
17.03.2020Customer 442Product Group 2Product Name 99239229141 %229141 %
17.03.2020Customer 442Product Group 2Total1445711457013 %2291463 %
17.03.2020Customer 442Product Group 5Product Name 1423865651 %65651 %
17.03.2020Customer 442Product Group 5Product Name 1462065650 %65650 %
17.03.2020Customer 442Product Group 5Product Name 1821965650 %65650 %
17.03.2020Customer 442Product Group 5Total77196950 %65651 %
17.03.2020Customer 442Total 147301680079 %3510342 %
17.03.2020Total  147301680079 %3510342 %

 

 

Regards

Andreas

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

 

I am not clear about your question but try these measures

 

My total revenue = SUM(Data[My revenue])

Item Group total revenue = MIN(Data[Revenue total Item group in store])


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
rorand
Helper I
Helper I

Anybody have a solution for this?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.