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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Margin Divisible by 5?

Hi,

I am looking to find a calculation that will tell me whether an item was sold at a margin divisible by five or not. i.e. ..., 35%, 40%, 45%, 50%, ... etc. I figured it would be simple using the MOD function. I tried each of the following

DivisibleBy5 = IF(MOD([Margin], 0.05) = 0, "Yes", "No")
DivisibleBy5 = IF(MOD([Margin] * 100, 5) = 0, "Yes", "No")

 Each give me an error saying "An argument of function 'MOD' has the wrong data type or the result is too large or too small". 

 

My [Margin] is a decimal number and classified as such. Any idea what's going wrong? Any other ways to get the result I'm looking for?

 

Thanks, 
Ryan

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@MattAllington

 

Sale Prices of $0.00 were creating -infinity values which was screwing it up. I stacked another IF statement on top of the other, saying IF([Sale]=0, IF(MOD([Margin], .05) = 0, "True", "False"), "False")

View solution in original post

12 REPLIES 12
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Please check the data type of the column [Margin]. If it is text, the formula will return #ERROR and you should change it to decimal number.

 

Thanks,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MattAllington
Community Champion
Community Champion

Is margin a measure or a calc column? Is DivisibleBy5 a measure or a calc column?



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Anonymous
Not applicable

@MattAllington 

 

Both are calculated columns. I want it to calculate per row.

Well it looks right. Can you post a sample of the values in the margin column?



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Anonymous
Not applicable

here is my formula and it works fine.  So I have to think something strange is happening to your data column.    Do you have any rougue values somewhere in the column?  Try writing a calc column =Max(table[total cost margin]) and see what you get

 

pct.png



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Anonymous
Not applicable

@MattAllington

 

Sale Prices of $0.00 were creating -infinity values which was screwing it up. I stacked another IF statement on top of the other, saying IF([Sale]=0, IF(MOD([Margin], .05) = 0, "True", "False"), "False")

Anonymous
Not applicable

Hi,

I am looking to find a calculation that will tell me whether an item was sold at a margin divisible by five or not. i.e. ..., 35%, 40%, 45%, 50%, ... etc. I figured it would be simple using the MOD function. I tried each of the following

DivisibleBy5 = IF(MOD([Margin], 0.05) = 0, "Yes", "No")
DivisibleBy5 = IF(MOD([Margin] * 100, 5) = 0, "Yes", "No")

 Each give me an error saying "An argument of function 'MOD' has the wrong data type or the result is too large or too small". 

 

My [Margin] is a decimal number and classified as such. Any idea what's going wrong? Any other ways to get the result I'm looking for?

 

Thanks, 
Ryan

Try creating a calculated column that just uses the inner formula

Eg. Column = mod ([margin] , 5)

And what does that show?

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

@alanhodgson 

That results in an error. "The result of a conversion or arethmatic operation is either too large or too small.

@Phil_Seamark 

The calculated column  gives me "An argument of function 'MOD' has the wrong data type or the result is too large or too small" again. 

Try MOD (int ([margin]*100) ,5)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hey @Anonymous,

 

The MOD function can be expressed in terms of the INT function: MOD(n, d) = n - d*INT(n/d)

 

Try this and see if the same error occurs:

 

DivisibleBy5 = IF(([Margin] - (0.05)*INT([Margin]/0.05)) = 0, "Yes", "No")

Hope this helps,

 

 

Alan

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors