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
Alessandra
Helper I
Helper I

Calculate weighted distribution in a matrix

Hi everyone,

 

I'm trying to calculate how many products are in each bussiness by brand and manufacturer, 

I already have the denominator of the weighted distribution, which is:

 

CALCULATE(SUM([VolSales]);ALLSELECTED(Table[Manufacturer]);ALLSELECTED(Table[Brand]))

 

The result of this measure gives me the total volume sales, but I want to calculate the volume sale of each brand by manufacturer.

Any ideas? 

 

Thanks.

1 ACCEPTED SOLUTION

Hi @Alessandra,

 

Based on my test, the formula below should work in your scenario. Smiley Happy

Measure = 
var businessIDs = DISTINCT(Hoja1[BusinessID])
return
CALCULATE(SUM(Hoja1[SalesVolume]),FILTER(ALL(Hoja1),CONTAINS(businessIDs,[BusinessID],Hoja1[BusinessID])))

r2.PNG

Here is the sample pbix file for your reference.

 

Regards

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Can you supply some sample data, sample output and the entire measure formula? What is your numerator?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler,

 

 

This is what I have of the numerator, but I don't know how to calculate the sales volume by business ID for each manufacturer and brand.

 

Numerator= CALCULATE(SUMX(SUMMARIZE(Table;Table[FechaD]);CALCULATE(SUMX(SUMMARIZE(Table;Table[BusinessID]);Table[SalesVolume])))))

 

In this picture, the red numbers are the numerator ( what I want to calculate), and the total is the denominator that I already have.

Captura.JPGCaptura11.JPG

 

 

Hi @Alessandra,

 

Is all the data in the same table or in different tables?

 

Could you post your real table structures(including the relationships) with some sample/mock data which can help us reproduce the issue, so that we can better assist on it? It's even better to just share a sample pbix file which can reproduce the issue. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploadingSmiley Happy

 

Regards

Hi @v-ljerr-msft,

 

Thanks for answering.

All the data is in the same table.

I'm attaching an Excel where there is some of the data that I have in power bi and in that file there is a sample of what I'm trying to do in power bi, which is the sales for each category and value where all the businesses are present. For example, for this category and this value I want to see all the business where there are sales.

There is also a sheet named SQL where there is a query for calculting the distribution.

 

PS: Take as example ONLY the table from the right, the table from the left is just to see the difference of the sales per category and sale of all businesses where the category is present (what is trying to do in power bi) . The data from the table from the right was calculated manually and the steps are at the bottom.

Thanks in advance 😄

 

https://drive.google.com/file/d/1PT4u3XxhD2TGbyDo87hP20MsRCQWdD0p/view?usp=sharing

 

Hi @Alessandra,

 

Based on my test, the formula below should work in your scenario. Smiley Happy

Measure = 
var businessIDs = DISTINCT(Hoja1[BusinessID])
return
CALCULATE(SUM(Hoja1[SalesVolume]),FILTER(ALL(Hoja1),CONTAINS(businessIDs,[BusinessID],Hoja1[BusinessID])))

r2.PNG

Here is the sample pbix file for your reference.

 

Regards

@v-ljerr-msft

Thank you so much ! It's just what I needed 😄

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.