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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
v-rzhou-msft
Community Support
Community Support

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
v-rzhou-msft
Community Support
Community Support

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors