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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

IF statement in dax

Hello!!

I have a question about IF en DAX, I hope someone  could helpme

 

I have this values

10000

345.67

897.01

100

750

783

321.45

890.5

0

etc

 

I want to check if the number afther the . (dot) is 00 and im trying with this,

 

Value.00 = IF(MOD('MyTable'[TOTAL],SIGN('MyTable'[TOTAL))=00,1,0)

 

but I have this error:

Division by zero has occurred when evaluating function 'MOD'.

 

Are not sure what others options can use.

 

Thanks for the help

Mónica

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi Mónica,

 

Try this formula, please.

Column =
IF (
    SEARCH ( ".", [Value],, 9999 ) = 9999,
    1,
    IF ( RIGHT ( [Value], 2 ) = "00", 1, 0 )
)

IF_statement_in_dax

 

Best Regards,

Dale

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

View solution in original post

6 REPLIES 6
v-jiascu-msft
Employee
Employee

Hi Mónica,

 

Try this formula, please.

Column =
IF (
    SEARCH ( ".", [Value],, 9999 ) = 9999,
    1,
    IF ( RIGHT ( [Value], 2 ) = "00", 1, 0 )
)

IF_statement_in_dax

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

HI @v-jiascu-msft

 

Thanks for your help!!

It works perfect

 

Greetings 

Mónica

Anonymous
Not applicable

Hi @Anonymous

 

Try this:

 

Column = IF(RIGHT(Table[Total,2)="00", 1,0)

 

Thanks
Raj

Anonymous
Not applicable

Hi @Anonymous

 

Thanks for your reply.

 

This option doesnt work for me, because the numbers like

 

1000

750

 dont show the .00 but its has it.

with this opcion only show me the 1000 and the 750 dont show me, but should it.

 

Thanks again

Monica

I'm sure there are lots of ways to do this.

 

You could try the Quotient function like         QUOTIENT(scores[Num1],1) to get the number on the LHS of the decimal point.

Then subtract that number from the original.  If the result is zero then the condition (i.e is it a whole number) is true.

 

I don't know whether you are effectively testing for a whole number or whether you also consider the condition true for numbers like 5.001 

You can change the algorithm slightly to cope with these numbers

Anonymous
Not applicable

I hope your data type is decimal, so if you set the number of decimal to 2, you will have 1000.00, 745.34.And ths formula will work.

 

Please let me know if you see any issues.

 

Thanks

Raj

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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