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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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>


Follow on LinkedIn
@ 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 =


Follow on LinkedIn
@ 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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.