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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
SachinC
Helper V
Helper V

Percentage Calculation

Hi,
I want a new calculated field so that it can calculate Percentage based on two fields by Route number.
 
E.g.
My datagrid currently contains 3 columns
Field 1: Route from Table A
Field 2: Drops from Table B
Field 3: Returns (which is Count of Customer) from Table A
This currently looks like this:-
Route   TotalDrops    Returns
1       100    5
2       100  10
3 50  25
4 10  5
I want the new field for PercentageReturns to be grouped by Route, so that it calculates the Percentage based on Returns and TotalDrops by Route.
E.g.
Route   TotalDrops    Returns PercReturns
1       100    5 5
2       100  10 10
3 50  25 50
4 10  5 50
How do I do this please?
Thanks
2 REPLIES 2
sturlaws
Resident Rockstar
Resident Rockstar

Hi @SachinC ,

 

your specifications is a bit short when it comes to what your desired outcome is. Here is the code for creating a calculated column:

PercentageReturns =
VAR _route =
    CALCULATE ( SELECTEDVALUE ( 'Table'[Route] ) )
VAR _drops =
    CALCULATE (
        SUM ( 'Table'[TotalDrops] );
        FILTER ( ALL ( 'Table' ); 'Table'[Route] = _route )
    )
VAR _returns =
    CALCULATE (
        SUM ( 'Table'[Returns] );
        FILTER ( ALL ( 'Table' ); 'Table'[Route] = _route )
    )
RETURN
    DIVIDE ( _returns; _drops )

 

keep in mind that when you aggregate like this in a calculated column, the value is repeated for each route, and if you later on sum over this column, it will be wrong.

 

 

For some reason that didn't work. Bear in mind Returns is a Count not Sum.

is there a ";" missing? It's suggesting it is.

Thanks!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.