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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.