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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sur27078
Regular Visitor

How to calculate % from single column

I'm currently working with a General Ledger (GL) dataset that includes only the following columns: Year, GL Account, Cost Center, Month, and Balance.

I’ve created a visual card that filters data based on GL accounts. For example, to calculate Gross Profit, I filter for GL Revenue and GL Expense accounts.

Now, I want to calculate the Gross Margin percentage, which is defined as:

Gross Margin % = Gross Profit / Total Revenue

My question is:
How can I calculate a percentage when I only have a single column for Balance?

can I calculate based on 2 visual cards?

 

sur27078_2-1757705737249.png

 

sur27078_1-1757705659968.png

 

 

Thanks,

Sur

1 ACCEPTED SOLUTION
GeraldGEmerick
Solution Sage
Solution Sage

@sur27078 You should be able to do something like the following:

Gross Margin % =
VAR _TotalRevenue = CALCULATE( SUM( 'Table'[Balance]), ALL( 'Table' ) )
VAR _GrossProfit = CALCULATE( SUM( 'Table'[Balance] ), FILTER( ALL( 'Table' ), [GL_Account] IN { "5014", "4508" } ) )
VAR _Return = DIVIDE( _GrossProfit, _TotalRevenue, 0 )
RETURN _Return

You would need to modify this for whatever your GL_Account codes are for however you are filtering your Revenue and Gross Profit card visuals.

View solution in original post

5 REPLIES 5
sur27078
Regular Visitor

@GeraldGEmerickIt seems to be working, but how can I filter by month and cost center?

sur27078_0-1757714729520.png

 

@sur27078 You could use ALLSELECTED instead of ALL like so perhaps:

Gross Margin % =
VAR _TotalRevenue = CALCULATE( SUM( 'Table'[Balance]), ALLSELECTED( 'Table' ) )
VAR _GrossProfit = CALCULATE( SUM( 'Table'[Balance] ), FILTER( ALLSELECTED( 'Table' ), [GL_Account] IN { "5014", "4508" } ) )
VAR _Return = DIVIDE( _GrossProfit, _TotalRevenue, 0 )
RETURN _Return

@GeraldGEmerick THANK YOU SO MUCH. it's working.

@sur27078 Very glad to hear!

GeraldGEmerick
Solution Sage
Solution Sage

@sur27078 You should be able to do something like the following:

Gross Margin % =
VAR _TotalRevenue = CALCULATE( SUM( 'Table'[Balance]), ALL( 'Table' ) )
VAR _GrossProfit = CALCULATE( SUM( 'Table'[Balance] ), FILTER( ALL( 'Table' ), [GL_Account] IN { "5014", "4508" } ) )
VAR _Return = DIVIDE( _GrossProfit, _TotalRevenue, 0 )
RETURN _Return

You would need to modify this for whatever your GL_Account codes are for however you are filtering your Revenue and Gross Profit card visuals.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.