Forum Discussion
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:
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:
Corrected Measure:
Avg Margin % =VAR AvgUnitPrice = AVERAGEX('Sales Table', 'Sales Table'[unit price])VAR AvgUnitCost = AVERAGEX('Sales Table', 'Sales Table'[unit cost])RETURNDIVIDE(AvgUnitPrice - AvgUnitCost,AvgUnitPrice,0)Hope it worksDid I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
2 Replies
- rajendraongole1
Super User
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:
Corrected Measure:
Avg Margin % =VAR AvgUnitPrice = AVERAGEX('Sales Table', 'Sales Table'[unit price])VAR AvgUnitCost = AVERAGEX('Sales Table', 'Sales Table'[unit cost])RETURNDIVIDE(AvgUnitPrice - AvgUnitCost,AvgUnitPrice,0)Hope it worksDid I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!- gbarr12345
Post Prodigy
That worked, thank you so much for your help!!!