Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors