Forum Discussion
Calculate weighted distribution in a matrix
- 8 years ago
Hi Alessandra,
Based on my test, the formula below should work in your scenario. :smileyhappy:
Measure = var businessIDs = DISTINCT(Hoja1[BusinessID]) return CALCULATE(SUM(Hoja1[SalesVolume]),FILTER(ALL(Hoja1),CONTAINS(businessIDs,[BusinessID],Hoja1[BusinessID])))
Here is the sample pbix file for your reference.
Regards
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 uploading. :smileyhappy:
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 :D
https://drive.google.com/file/d/1PT4u3XxhD2TGbyDo87hP20MsRCQWdD0p/view?usp=sharing
- v-ljerr-msft8 years ago
Microsoft Employee
Hi Alessandra,
Based on my test, the formula below should work in your scenario. :smileyhappy:
Measure = var businessIDs = DISTINCT(Hoja1[BusinessID]) return CALCULATE(SUM(Hoja1[SalesVolume]),FILTER(ALL(Hoja1),CONTAINS(businessIDs,[BusinessID],Hoja1[BusinessID])))
Here is the sample pbix file for your reference.
Regards
- Alessandra8 years ago
Helper I
Thank you so much ! It's just what I needed :D