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

Using Today() in a custom column

Hi, I want a Pass/Fail column where if logical status - 6 and the record hasn't been updated for a year then it's a fail, otherwise a pass. I'm creating a custom column with the following:-

 

L16 = if [logical_status]=6 then if [DATE_UPDATED]<today()-365 then "Fail" else "Pass" else "Pass"

 

Now, it says there are no syntax errors but when I hit the OK button it then says it couldn't recognise the name "today". I'm sure it's really obvious but I'm struggling as a new powerquery user so any friendly advice would be welcomed 🙂

3 REPLIES 3
MFelix
Super User
Super User

Hi @Anonymous .

 

The Query editor uses M Language and the syntax is different from DAX and excel you should use the syntax below instead of today

 

 

Date.From(DateTime.LocalNow())

 

 

Regards.

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Thanks MFelix, that certainly helped me on the way and I'm now studying the PowerQuery M language in more depth.

 

Could you have a look over this for me?

 

=if [logical_status]=6 then if [DATE_UPDATED] < Date.From(DateTime.LocalNow()) - 365 then "Fail" else "Pass" else "Pass"

 

Should be saying:

if the status is 6 AND if the date updated is more than a year ago then it's a fail, else it's a pass.

 

Am I on the right lines or should I be trying a different tack? It's coming up with "Error" in the new column although the syntax is passing muster. For info the status column is an integer and the date column is date only so I can't see where the problem lays!

 

Thanks again for being kind to a noob 😉

Hi @Anonymous ,

 

You have two then on your statetment the syntax should be:

 

=if [logical_status]=6 and [DATE_UPDATED] < Date.From(DateTime.LocalNow()) - 365 then "Fail" else "Pass"

 

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



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.