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
Sagejah9
Helper III
Helper III

How to add a measure to a row of a matrix that is predefined?

I am preparing a PnL using the matrix visual in PowerBI with Months as Columns and Line Items as rows nested. All the data is coming from one table and all group names and line items are in the right order. The rows that are blank require calculations but the line names exist in the table. No values. I tried using a switch case but the measure returns blank. This a technique I am seeing for creating custom subtotal. Any Help, please?

1 ACCEPTED SOLUTION

Hi @Sagejah9,

 

According to you expected output, may be you can not do this.

It will  pivot all the table when you drop column into values.

As:

v-xulin-mstf_0-1612345854727.png

 

Best Regards,

Link

View solution in original post

5 REPLIES 5
v-xulin-mstf
Community Support
Community Support

Hi @Sagejah9,

 

Try measure as:

Measure =

IF(

   HASONEFILTER(Table1[GroupName]),

   SUM(Table1[Amount]),

   [Total Revenue]-[Total Expenses])

And then modify the name of ‘subtotal’:

v-xulin-mstf_0-1612339818025.png

 

Here is the output:

v-xulin-mstf_1-1612339818041.png

 

Here is the demo, please try it: How to add a measure to a row of a matrix that is predefined?

 

Best Regards

Link

 

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

This is great, thanks! but how can I keep the Row totals for Revenue and Expense  and used the NetProfit row that's already in the table, just that its values are either blank or 0, I would like to replace this with a measure. So, like going through row items (Groupnames) and allocating that measure when necessary.    

Hi @Sagejah9,

 

According to you expected output, may be you can not do this.

It will  pivot all the table when you drop column into values.

As:

v-xulin-mstf_0-1612345854727.png

 

Best Regards,

Link

vanessafvg
Super User
Super User

can you share the calculation you are using and show with some visuals what you want to see.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




I made a sample PnL in excel to show the structure in the matrix visual and where I would like the calculated measure to fill. Not able to share the visual due to data privacy. 

Sagejah9_0-1612122724147.png

Measures:
Total Revenue = CALCULATE(SUM('Table1'[Amount]),'Table1'[GroupName] ="Revenue")
Total Expenses = CALCULATE(SUM('Table1'[Amount]),'Table1'[GroupName] ="Expenses")
Net Profit = [Total Revenue] - [Total Expenses]

Values_Measure = SWITCH(SELECTEDVALUE('Table1'[GroupName]), "Profit Before Tax", [Net Profit], CALCULATE(SUM('Table1'[Amount]))

 

I would like the resulting Matrix Table to look like this using the Values_Measure Measure in the row 

Sagejah9_0-1612127970840.png

 

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.