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

Help with converting IF, ISNUMBER excel funtiotion into Power BI

Hello, 

 
I am trying to create the following formula in power BI.  I try to break it down and try to use it by IF and Switch. I was not able to get the result I want. Can anybody please help me with this? 
 
Screenshot of excel with the column.
Capture.PNG

 

Formular 
=IF(ISNUMBER($K2),$K2-$J2,IF($J2>TODAY(),"",TODAY()-$J2))
 
Thank you so much
 
 
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@danzidpp

https://community.powerbi.com/t5/Community-Blog/Excel-to-DAX-Translation/ba-p/1060991

The DAX functions are identical to the Excel functions in your case, so:

Column = 
  IF(ISNUMBER([Column K]),
    [Column K] - [Column J],
    IF([Column J] > TODAY(),
      "",
      TODAY() - [Column J]
    )
  )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@Anonymous , if J is number that it can not be compared with today and if it is then you need to return same type data

 

try like

Column =
IF(isnumber([Column K]),
[Column K] - [Column J],
IF([Column J] > TODAY(),
blank(),
datediff(TODAY() , [Column J], day)
)
)

Anonymous
Not applicable

@amitchandak thank you , Its good to know that I can use excel funtion on power BI, but I am getting an error both my date colunms are formatted to date. Not sure why is that. Any Idea?

Capture.PNG

Not sure what this is translating to spanish. hopefully you can see it english

ryan_mayu
Super User
Super User

@Anonymous 

please try this

Column = if(ISNUMBER('Table'[record date]),'Table'[record date]-'Table'[date],if('Table'[date]>today(),blank(),today()-'Table'[date]))




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

Proud to be a Super User!




@ryan_mayu Thank you, but I am getting error. Please see below if you know anything

Greg_Deckler
Super User
Super User

@danzidpp

https://community.powerbi.com/t5/Community-Blog/Excel-to-DAX-Translation/ba-p/1060991

The DAX functions are identical to the Excel functions in your case, so:

Column = 
  IF(ISNUMBER([Column K]),
    [Column K] - [Column J],
    IF([Column J] > TODAY(),
      "",
      TODAY() - [Column J]
    )
  )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler  Good to know that I can use excel funtion, but i ma getting an error when I do that. (Both my Due Date and Actual Delivary Date are on Date format). I am not sure what is variant-type cannot be used. Any idea? Thank you 

 


Capture.PNG

@Anonymous - Yes, you will need to either always return text or numbers. You formula returns text sometimes and numbers other times, that is not allowed in DAX. So you can either replace your "Other" with 0 or some other number.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.