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
vignesh21
Frequent Visitor

Problem in checking is date in powerbi column creation

Untitled1.pngthis is the error i am getting when i create a column AFELeeway.

5 REPLIES 5
Greg_Deckler
Super User
Super User

Seems like you are mixing M syntax with DAX syntax. They are two different languages. See this article:

 

https://community.powerbi.com/t5/Community-Blog/The-Languages-of-Power-BI/ba-p/69104

 

DAX IF syntax is exactly like Excel IF syntax.

 

IF(<condition>, <true>, <false>)

 

M syntax is:

 

if <condition> then <true> else <false>


@ 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...

Untitled2.pngstill error is coming.Error is coming near is date.How to solve it.

"is" is not valid syntax for either DAX or M, you need to use =


@ 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...

I am getting error as below:

Failed to resolve name 'date'. It is not a valid table, variable, or function name.

 

And my code is :

 

AFELeeway = if((Query1[FullAfeApproved] = date),(DATEDIFF(Query1[FullAfeApproved],Query1[EstimatedSpud],DAY)-Query1[parmAFELeeway]), (DATEDIFF(TODAY(),Query1[EstimatedSpud],DAY)-Query1[parmAFELeeway]))

 

Actually, I want to check whether the field is a proper date

 

@vignesh21,

Do you want to check that if the data type of FullAfeApproved column is date using dax? If so, it is not possible. 

What data type do you set for the FullAfeApproved column? All values of the FullAfeApproved column can only be a single data type(e.g, Date). If you change data type of FullAfeApproved column to date, you are able to directly use DATEDIFF() function, and you are able to check if a value of FullAfeApproved column equals/is greater/is less than to a specific date value. Here is an example for you.

AFELeeway = if(Query1[FullAfeApproved] <=TODAY(),(DATEDIFF(Query1[FullAfeApproved],Query1[EstimatedSpud],DAY)-Query1[parmAFELeeway]), (DATEDIFF(TODAY(),Query1[EstimatedSpud],DAY)-Query1[parmAFELeeway]))

 



Regards,
Lydia

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

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.