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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
hobbssj
Regular Visitor

Trouble with calculated date column

Hello,
 
I'm trying to add a column to use in a visual. The column will be displaying one of two options if the date in the "modidate" is 3 days prior to the current date.
 
The modidate contains a datatime data type. and is contained in the tasks table
 
ticketupdated = IF(DATEDIFF(TASKS[MODIDATE];today();day); <3; True(UptoDate), False(Needs update))
 
With the above I am getting a sytax error as well as a pop up message that says cannot find modidate.
 
I figure I'm refrencing the SQL data wrong, but I'm not sure how to fix it, can anyone advise? or suggest a better way to do this?
1 ACCEPTED SOLUTION

Hi, @hobbssj 

 

You need to modify your code,Like this:

= Table.AddColumn(#"Sorted Rows1", "ticketupdated", each if Date.From([date])>=Date.AddDays( Date.From(DateTime.LocalNow()),-3) and Date.From([date])<Date.From(DateTime.LocalNow())
then true 
else false)

2.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

4 REPLIES 4
amitchandak
Super User
Super User

@hobbssj , this can be like

ticketupdated = IF(DATEDIFF(TASKS[MODIDATE],today(),day) <3, True(), False())

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thanks,

 

That made a difference  however its still not working 

I added this to the custom column and it came out like this 

 

= Table.AddColumn(#"Sorted Rows1", "ticketupdated", each ticketupdated = IF(DATEDIFF(TASKS[MODIDATE],today(),day) <3, True(), False()))

 

and got 

Expression.Error: The name 'ticketupdated' wasn't recognized. Make sure it's spelled correctly.

 

I adjusted it 

 

= Table.AddColumn(#"Sorted Rows1", "ticketupdated", IF(DATEDIFF(TASKS[MODIDATE],today(),day) <3, True(), False()))

 

and now am getting 

 

Expression.Error: The name 'IF' wasn't recognized. Make sure it's spelled correctly

 

any thoughts?

Hi, @hobbssj 

 

You need to modify your code,Like this:

= Table.AddColumn(#"Sorted Rows1", "ticketupdated", each if Date.From([date])>=Date.AddDays( Date.From(DateTime.LocalNow()),-3) and Date.From([date])<Date.From(DateTime.LocalNow())
then true 
else false)

2.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

Just a quick update, we ended up getting our DBA to create a custom view on on the database. 

 

but I testted the Janey's soltuion and that worked as well 

 

Thanks for everyone help

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.