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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
usmansattar
New Member

Inserting Calculated Fields in rows in Matrix Visual

Hello All,

I am in a bit confusion with Matrix Visual.

I hava a PnL table which have fields (Group, SubGroup, Amount, Company, Month) 

I also made a Dim tabel for Group which have these info

GroupIndex
Sales Accounts1
Cost of Sales :2
Direct Expenses3
Gross4
Indirect Incomes5
Indirect Expenses6
Net7

 

The "Gross" and "Net" are not part of Fact table those are calculated with DAX.

My Fact table is as below

GroupSubGroupAmountCompanyMonth
Sales AccountsR-01 Revenues From Waste Treatment10818.09ABCJuly-23
Sales AccountsR-03 Revenues from Sales of Addititives and Fuels108728.87ABCJuly-23
Sales AccountsR-04 Revenues from Sales of Building Materials22384ABCJuly-23
Sales AccountsR-05 Revenues from Rental of Plant & Equipment22643.33DEFJuly-23
Sales AccountsSales Bills to Make475DEFJuly-23
Cost of Sales :Opening Stock837417.98DEFJuly-23
Cost of Sales :Add: Purchase Accounts593451.79DEFJuly-23
Cost of Sales :Less: Closing Stock174821.07FIGJuly-23
Direct ExpensesD-04 Operating Consumables69856.03ABCJuly-23
Direct ExpensesD-05 Logistics Costs10888.5DEFJuly-23
Direct ExpensesD-06 Utilities (Electricity, Water, Gas)4807.94FIGJuly-23
Direct ExpensesD-07 Direct Labour Cost165176.88ABCJuly-23
Indirect IncomesR-09 Revenue of Sales of Assets (book gain)140000ABCJuly-23
Indirect IncomesR-12 Recovery or Compensation Payments-108202ABCJuly-23
Indirect IncomesR-16 Revenue from Affiliate Companies-54905.53DEFJuly-23
Indirect ExpensesI-13 Telecommunication Expenses3066.71ABCJuly-23
Indirect ExpensesI-17 Office Supplies2337.3DEFJuly-23
Indirect ExpensesI-18 Banking Charges1068.75DEFJuly-23

Gross is 

Gross Profit = [Total Sales]-[Total Cost Of Sale]- [Total Direct Expense]
and Net is
Net profit = [Gross Profit]+ [Indirect income]-[Total Indirect Expense]
How can i display these two calculated values in rows after Direct Expense and Indirect Expense respectively inside matrix visual..
I made virtual table and union with dim table but then it only shows in a single column, not dividing Company wise and Month wise.
Struggling from a day to achieve this

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @usmansattar ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a measure. 

Measure = SWITCH(TRUE(),
SELECTEDVALUE('Fact table'[Group])="Direct Expenses",[Gross Profit],
SELECTEDVALUE('Fact table'[Group])="Indirect Expenses",[Net profit],
BLANK())

(3) Then the result is as follows.

vtangjiemsft_1-1692585618749.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @usmansattar ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a measure. 

Measure = SWITCH(TRUE(),
SELECTEDVALUE('Fact table'[Group])="Direct Expenses",[Gross Profit],
SELECTEDVALUE('Fact table'[Group])="Indirect Expenses",[Net profit],
BLANK())

(3) Then the result is as follows.

vtangjiemsft_1-1692585618749.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.