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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
tod
Frequent Visitor

Calculation between rows with conditions

Hi,

I'm trying to create a custom column showing % from data between rows. Best way to show what I'm trying to do is the data set here:

Column AColumn BColumn CCustom Column D
1A202%
1B1000100%
1C758%
1D25025%
2A302%
2B1500100%
2C1007%
2D503%
3A101%
3B800100%
3C203%
3D203%

 

The % calculation is always against B, but B repeats in Column B because Column A has several sets like different years. DAX or M formula is fine, but the data set is very large so perfomance is a consideration. Appreciate any and all help!

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi @tod  ,  

 

You could create a measure by the following formula: 

Custom Column D =
MAX ( [Column C] )
    / CALCULATE (
        MAX ( 'Table'[Column C] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Column A] = MAX ( 'Table'[Column A] ) ),
        'Table'[Column B] = "B"
    )

The final output is shown below:  

v-yalanwu-msft_0-1620989413299.png

Best Regards,
Community Support Team_ Yalan Wu
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

3 REPLIES 3
v-yalanwu-msft
Community Support
Community Support

Hi @tod  ,  

 

You could create a measure by the following formula: 

Custom Column D =
MAX ( [Column C] )
    / CALCULATE (
        MAX ( 'Table'[Column C] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Column A] = MAX ( 'Table'[Column A] ) ),
        'Table'[Column B] = "B"
    )

The final output is shown below:  

v-yalanwu-msft_0-1620989413299.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.   

tod
Frequent Visitor

Thanks Pat. Using your formula, Columns A and C are summing as shown. They should remain in their original format. None of the columns are "summarized"; they are "Don't summarize".

tod_0-1620823136365.png

This is how I interpreted your formula:

 
Custom Custom =
VAR thisvalue = 'Table'[Column C]
VAR thisAvalue = 'Table'[Column A]
VAR thisAvalueB =
AVERAGEX (
FILTER ( 'Table', 'Table'[Column A] = thisAvalue && 'Table'[Column B] = "B" ),
'Table'[Column C]
)
RETURN
DIVIDE ( thisvalue, thisAvalueB )
 
Did I do this right?
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this column expression.  Rename the Table from PctOfB to your actual table name throughout.

 

PctOfBColumn =
VAR thisvalue = PctOfB[Column C]
VAR thisAvalue = PctOfB[Column A]
VAR thisAvalueB =
    AVERAGEX (
        FILTER ( PctOfB, PctOfB[Column A] = thisAvalue && PctOfB[Column B] = "B" ),
        PctOfB[Column C]
    )
RETURN
    DIVIDE ( thisvaluethisAvalueB )

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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