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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
JeffreyLau
New Member

Profit Per unit

All,

 

How can I get a return on the profit per unit as 13.79 in power BI?

 

Please see the below screenshot.  When it is done in excel calculated field, the total profit per unit returned correctly as 13.79 (1,394,716.39/101,145.1) but in Power BI, NaN is returned.  Please note that the first two rows need to be kept for use.  

 

Thanks!

 

 

Capture.PNG

1 ACCEPTED SOLUTION
Datatouille
Solution Sage
Solution Sage

Hi,

 

 

I guess you computed your Profit per unit as a calculated column using the DAX language in Power BI.

Because this is a ratio, you'd better use a measure rather than a calculated column. See more explanation here: https://exceleratorbi.com.au/calculated-columns-vs-measures-dax/

Ralph Kimball summarizes this concept with this sentence : "You should always do the ratios of the sum rather than the sum of the ratios"

 

So, in your example, go to 'Modelling' Tab, create the following measure:

ProfitPerUnit = Divide ( Sum(YourTable[Profit]) , Sum(YourTable[Unit]) , 0)

 

And use this brand new measure in the "values" of your tables & matrix.

View solution in original post

3 REPLIES 3
Datatouille
Solution Sage
Solution Sage

Hi,

 

 

I guess you computed your Profit per unit as a calculated column using the DAX language in Power BI.

Because this is a ratio, you'd better use a measure rather than a calculated column. See more explanation here: https://exceleratorbi.com.au/calculated-columns-vs-measures-dax/

Ralph Kimball summarizes this concept with this sentence : "You should always do the ratios of the sum rather than the sum of the ratios"

 

So, in your example, go to 'Modelling' Tab, create the following measure:

ProfitPerUnit = Divide ( Sum(YourTable[Profit]) , Sum(YourTable[Unit]) , 0)

 

And use this brand new measure in the "values" of your tables & matrix.

Thanks, it works now.  I tried the new measure before but did not know "Divide".  Now I know.  Thanks.

davehus
Memorable Member
Memorable Member

Are you using the Divide function in the measure? I can see a couple of columns with zero in them which maybe chasing the error.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.