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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
austinli37dot8
Regular Visitor

how to insert a "index" row in the matrix ?

austinli37dot8_1-1677644208584.png

 

This is the output I expect in the matrix; I try to insert a row called index, its category b/a, and this index how many b times of a, please help. Thank you.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @austinli37dot8 ,

 

I think you can custom row subtotal by measure to show index as you want.

You can transform your table as below.

RicoZhou_0-1678167515011.png

Measure:

 

Custom Total =
VAR _VALUE =
    SUM ( 'Table'[Value] )
VAR _a =
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[category] = "a" )
VAR _b =
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[category] = "b" )
VAR _INDEX =
    DIVIDE ( _b, _a )
RETURN
    IF ( HASONEVALUE ( 'Table'[category] ), _VALUE, _INDEX )

 

Result is as below.

RicoZhou_1-1678167536297.png

 

Best Regards,
Rico Zhou

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @austinli37dot8 ,

 

I think you can custom row subtotal by measure to show index as you want.

You can transform your table as below.

RicoZhou_0-1678167515011.png

Measure:

 

Custom Total =
VAR _VALUE =
    SUM ( 'Table'[Value] )
VAR _a =
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[category] = "a" )
VAR _b =
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[category] = "b" )
VAR _INDEX =
    DIVIDE ( _b, _a )
RETURN
    IF ( HASONEVALUE ( 'Table'[category] ), _VALUE, _INDEX )

 

Result is as below.

RicoZhou_1-1678167536297.png

 

Best Regards,
Rico Zhou

 

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

amitchandak
Super User
Super User

@austinli37dot8 , refer if this way of adding custom total can help

 

https://medium.com/@amitchandak/power-bi-formatted-p-l-with-custom-sub-totals-and-blank-rows-e39ca82...

 

Power BI How to get the P&L formatting right: https://youtu.be/C9K8uVfthUU
Power BI How to get two columns format Profit and Loss Statement(P&L) right: https://youtu.be/WLg85yiMgHI

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.