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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
ssutton
Frequent Visitor

CREATE CALULCATIONS ON VALUES FROM SELECT ROWS

I need to create a measure that DIVIDES the SUM of select rows in column A by the SUM of select rows in column B.

 

Amount of Overhead Cost + Amount of PTO = TOTAL COST

The TOTAL COST will be used in a measure to calculate percentage of cost to Revenue

 

My data is in SQL Database and is structured like this:

Date       Office     Column A              Column B      Amount
Jan-20    1234      Revenue                 Revenue           300
Jan-20    1234      Overhead Cost       Office                25
Jan-20    1234      Direct Expense        Mileage           100
Jan-20    5678      Revenue                 Revenue           300
Feb-20   5678      Overhead Cost        PTO                   25
Feb-20    5678     Direct Expense        Labor               100

 

I can provide a sample excel file with data shema and values via one drive.  The message will not post if I format the above data into a table. 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Try new measures like


cost = calculate(sum(table[Amount]),table[Column A] in{"Overhead Cost","PTO"})
revenue = calculate(sum(table[Amount]),table[Column A] ="Revenue")

Ratio =divide([cost],[revenue])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

Try new measures like


cost = calculate(sum(table[Amount]),table[Column A] in{"Overhead Cost","PTO"})
revenue = calculate(sum(table[Amount]),table[Column A] ="Revenue")

Ratio =divide([cost],[revenue])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you for your quick response.  This is very close, but the cost formula doesn't account for the "PTO" value being located in a different column,

 

cost = calculate(sum(table[Amount]),table[Column A] in{"Overhead Cost","PTO"})

 sum table amount Column A + sum table amount Column B

Helpful resources

Announcements
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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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