Reply
gbarr12345
Post Prodigy
Post Prodigy
Partially syndicated - Outbound

Help with Margin measure

Hi there,

 

I'm trying to create a measure to calculate the profit margin for customers using the average unit price and average unit cost as in my data these customers would have multiple transactions.

 

I've tried using a measure which is below but am getting the following error - 

'Too few arguments were passed to the DIVIDE function. The minimum argument count for the function is 2.'

 

I've attached my sample data below:

 

https://drive.google.com/file/d/1Kyg3V90tV7Q2kYmclkHiQgUQO3oYr8zg/view?usp=sharing

 

The measure that I used is below:

 

Margin Test =
Margin Test =
DIVIDE(
    AVERAGEX('Module Sales with Inventory', 'Module Sales with Inventory'[unit price]) - AVERAGEX('Module Sales with Inventory', 'Module Sales with Inventory'[unit cost]), AVERAGEX('Module Sales with Inventory', 'Module Sales with Inventory'[unit price]))
 
Is there a good amrgin measure that I could use using the fields Unit price and Unit cost or if you know of any corrections to the above measure?
 
Many Thanks in advance.
1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Syndicated - Outbound

Hi @gbarr12345 - The issue with the measure you created is that it lacks a necessary argument for the divide function, which expects at least two arguments.

 

i have commented your dax measure below:

rajendraongole1_0-1719987903017.png

 

Corrected Measure:

 

Avg Margin % =
VAR AvgUnitPrice = AVERAGEX('Sales Table', 'Sales Table'[unit price])
VAR AvgUnitCost = AVERAGEX('Sales Table', 'Sales Table'[unit cost])
RETURN
DIVIDE(
    AvgUnitPrice - AvgUnitCost,
    AvgUnitPrice,
    0
)
 
Hope it works
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
rajendraongole1
Super User
Super User

Syndicated - Outbound

Hi @gbarr12345 - The issue with the measure you created is that it lacks a necessary argument for the divide function, which expects at least two arguments.

 

i have commented your dax measure below:

rajendraongole1_0-1719987903017.png

 

Corrected Measure:

 

Avg Margin % =
VAR AvgUnitPrice = AVERAGEX('Sales Table', 'Sales Table'[unit price])
VAR AvgUnitCost = AVERAGEX('Sales Table', 'Sales Table'[unit cost])
RETURN
DIVIDE(
    AvgUnitPrice - AvgUnitCost,
    AvgUnitPrice,
    0
)
 
Hope it works
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Syndicated - Outbound

That worked, thank you so much for your help!!!

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)