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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Calculated Measure Returns Incorrect Results

Hi,

I am trying to calculate a gross profit based on sales and COGS.

I have two measures: [total sales] and [total cost of sales and services].

I created a measure: 

Gross Profits = [Total Sales]-[Total Cost Of Sales and Services]
But it returns incorrect results:
 
 
Screenshot 2021-06-23 102606.png

 

e.g, the first line should be (320091-218214=101877) and not 1733810.

 

Can you please help?

thank you!

Maya

 
4 REPLIES 4
Anonymous
Not applicable

Total sales was 

Total Sales = sum(Sales[Sales ($K)])
Cost of sales and services was this column (cost of sales alllocated by product):
Cost Of Sales and Services =
Sales[AllocationRate]*CALCULATE(sum(lvl2_Expenses[Cost of sales and services]))
and then this measure:
Total Cost Of Sales and Services = sum(Sales[Cost Of Sales and Services])

Cost of sales total seems correct when I display it- but the measure would not work.
Unfortunately, the data is sensitive so I cannot send it....

@Anonymous , I see this as a problem, multiplication should happen at line level or you should force a level

assuming AllocationRate is also a measure

on a common dimension

sumx(Values(Dim[Dim]),[AllocationRate]*CALCULATE(sum(lvl2_Expenses[Cost of sales and services])))

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
Anonymous
Not applicable

Hi Amit,

AllocationRate is a column. would that syntax still work?

amitchandak
Super User
Super User

@Anonymous , seem strange, can share calculations for   [Total Sales]-[Total Cost Of Sales and Services].

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

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.

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.