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 to add a row to calculate percentage in a matrix?

Hi, here is a question how to create a measure on row level in matrix.

for example, the last row is the result of a division, which 'competitive' is numerator and the row 'total' is denominator, do you have any good ideas?

Thank you.微信图片_20220215185738.png

 

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

I created some data:

vyangliumsft_0-1645173761033.png

You can achieve this using create new table

Here are the steps you can follow:

1. Create calculated table.

Row_SubTotal =
var _summarize=SUMMARIZE(
    'Row_Table',[Date],
    "Name","Sum",
    "Value",SUM(Row_Table[Value]))
return
UNION('Row_Table',_summarize)

vyangliumsft_1-1645173761036.png

Summarize_Table =
var _summarize=SUMMARIZE(
    'Row_SubTotal',[Date],
    "Name","Total",
    "Value", 
   FORMAT( DIVIDE(SUM('Row_SubTotal'[Value])/2,SUM('Row_Table'[Value])),"Percent"))
return
UNION('Row_SubTotal',_summarize)

vyangliumsft_2-1645173761038.png

2. Result:

There are two things to note here:

1. You can replace "Competitve" with ''Sum', because Power BI sorts alphabetically by default. In my data, it is ABCDE. If it is written as "Sum", it will be in alphabetical order S>E&&S<T , placed after E and before Total.

2. Because the data format of a column must be the same, if one value is Whole number and the other is Percent, there will be a data type error, so I convert it to Text.

vyangliumsft_3-1645173761041.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Anonymous
Not applicable

Thank you. It's seems splendid, it's a good idea when data columns like that.

My biggest problem is the data is not in that form and the data should be shown originally, filtered by slicer, and add a row to calculate the percent based on certain other rows. So use a matrix to transpose is not meet the needs.

1.png

for example, show those data in a table and 4 slicers: region, org3.2, org4.2, org5, and add a row to calculate evary value column, the numerator  is the number when dim_2 is  'competitive' is and denominator is the number when dim_2 is 'firm' (total active%=160/217, fufilled%=65/35)

Is there to be a solution that add a row like that in this table, or add in new table with the result of calculation below the details table that remain the same slicers and same column name? Thank you.

amitchandak
Super User
Super User

@Anonymous , you can not add a row, You can change total using isinscope or hasonevalue to % total

 

https://xxlbi.com/blog/new-dax-function-isinscope/

https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

 

Or you use this excel/power bi merge approach by Curbal

https://www.youtube.com/watch?v=IISYzTaIyu4

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.