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
Anonymous
Not applicable

How do you calculate a conditional percent in a matrix?

Hello-

 

I'm very new to Power BI and would appreciate some advice. I have the following data table:

data table.png

I want to have this output:

 

matrix output.png

 

How do you write a measure that sums a specific Producer's sales to their own region (Domestic Sales) divided by the total of what that Producer sells to get % Domestic Sales?

 

TIA!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi Eric-

 

Thank you! I ended up creating 3 measures, one for each producer region. For example: 

Europe Domestic % = (SUMX(Filter('Summary Table', 'Summary Table'[Producer]="Europe"),[Europe]) / (SUMX(Filter('Summary Table', 'Summary Table'[Producer]="Europe"),[Total]) ))

 

But your solution would be better.

 

Sample data: 

PRODUCER JAPAN  NORTH AM  EUROPE  KOREA  TAIWAN  CHINA  ROW  Total 
Europe1081015105563
North America85510515856
Japan1010101010101070
Korea,Taiwan, China & Row combined510551061051
Europe1051010510656
North America55155155858
Japan555555535
Korea,Taiwan, China & Row combined5101010681059
Europe10155510101570
North America15101015561273
Japan15151515151515105
Korea,Taiwan, China & Row combined1055688547

View solution in original post

7 REPLIES 7
Eric_Zhang
Employee
Employee


@Anonymous wrote:

Hello-

 

I'm very new to Power BI and would appreciate some advice. I have the following data table:

data table.png

I want to have this output:

 

matrix output.png

 

How do you write a measure that sums a specific Producer's sales to their own region (Domestic Sales) divided by the total of what that Producer sells to get % Domestic Sales?

 

TIA!


@Anonymous

Could you post any sample data? Basically I think you can create some measure like.

percentage = divide(sum('Table'[producer sales]),calculate(sum('Table'[domestic sales]), ALLEXCEPT('Table','Table'[region])))
Anonymous
Not applicable

Hi Eric-

 

Thank you! I ended up creating 3 measures, one for each producer region. For example: 

Europe Domestic % = (SUMX(Filter('Summary Table', 'Summary Table'[Producer]="Europe"),[Europe]) / (SUMX(Filter('Summary Table', 'Summary Table'[Producer]="Europe"),[Total]) ))

 

But your solution would be better.

 

Sample data: 

PRODUCER JAPAN  NORTH AM  EUROPE  KOREA  TAIWAN  CHINA  ROW  Total 
Europe1081015105563
North America85510515856
Japan1010101010101070
Korea,Taiwan, China & Row combined510551061051
Europe1051010510656
North America55155155858
Japan555555535
Korea,Taiwan, China & Row combined5101010681059
Europe10155510101570
North America15101015561273
Japan15151515151515105
Korea,Taiwan, China & Row combined1055688547

Hi,

 

Given this dataset, what result are you expecting?


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

Desired output from the sample data provided above:

 ProducerDomestic SalesTotal Producer Sales% Domestic
Europe25                                   18913%
North America20                                   18711%
Japan30                                   21014%
Korea,Taiwan, China & Row combined92                                   15759%
 Total167                                   74322%

Hi @Anonymous,

 

You may refer to my solution here.

 

Hope this helps.


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

 

@Anonymous

 

here you go

 

Snap.PNG

 

& find the attached file here

Anonymous
Not applicable

Thank you @chethan for the file. 

I'm looking for the DAX query/ies that would calculate "Domestic Sales %", so some little logic needs to be included into the query given that I have mulitple producers shipping to multiple regions.

 

The query needs to "find" the total domestic sales to the regions as well as the grand total of the producers sales as illustrated by the sample below.

 

Domestic Sales for:

Europe = "25" (10+10+5)

Japan "30" (10+5+15)

North America "20" (5+5+10)

 

Grand Total Producer Sales:

Europe = "189" (63+56+70)

Japan "210" (70+35+105)

North America "187" (56+58+73)

 

and then calculate Domestic %:

Europe 25  / 189  = 13%

Japan 30  / 210 = 14%

North America 20  / 187  = 11%

 

At this point I'm going to stick with the 3 measures that I created. I'm sure that there is a more eloquent solution out there but my hack will do for now.

 

Thank you again for your assistance!

 

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.