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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
NumeroENAP
Helper III
Helper III

Getting errors with a column transformation (future dates to today's date)

Hi,

 

I want to replace future dates in my column by today's date, but i'm only getting errors. 

 

My query : 

= Table.TransformColumns(#"LastLine", {"Date created", each if [Date created] > (DateTime.FixedLocalNow()) then Date.From(DateTime.FixedLocalNow()) else [Date created], type date})

 

My data = a simple date column (type date)

 

The message showed : 

Expression.Error : Sorry... We coulnd't apply access to field type Date.
Details :
Value=2020-01-24
Key=Date created

 

I tried to change my column to format TimeDate, but it returns the same error message with «type DateTime» at the end...

 

Thanks!

1 ACCEPTED SOLUTION

here the correct version of your syntax

 

= Table.TransformColumns(#"LastLine", {"Date created", each if _ > (DateTime.FixedLocalNow()) then Date.From(DateTime.FixedLocalNow()) else _, type date})



If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

View solution in original post

9 REPLIES 9
Jimmy801
Community Champion
Community Champion

Hello @NumeroENAP 

 

this is a double post

link 

use the syntax that is specified there to solve your problem

 

= Table.TransformColumns
  (
      #"Column", 
      {
         {
            "Date created", 
            each if _ > Date.From(DateTime.FixedLocalNow()) then Date.From(DateTime.FixedLocalNow()) else _,
            type date
         }
      }
   )

 

Fix your syntax according to this

 

Jimmy

@Jimmy801  When I saw that my query was bad today, I tried to fix it according to what you wrote me, but I'm still stucked with my problem. 

here the correct version of your syntax

 

= Table.TransformColumns(#"LastLine", {"Date created", each if _ > (DateTime.FixedLocalNow()) then Date.From(DateTime.FixedLocalNow()) else _, type date})



If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Well, I found my problem on https://docs.microsoft.com/fr-fr/power-bi/service-admin-troubleshooting-power-bi-personal-gateway

 

It was indeed due to the data source.

 

I checked my datas, and there was a single data that wasn't right... 

Hello

 

well... your syntax posted in the first post will never work, independent from your data source

 

Bye

 

Jimmy

Urgh, I thought it was the data that was the problem, but no...

 

I tried to compare my query with the one you provided, but it still doesn't work. 

 

Mine : 

 

= Table.TransformColumns(#"LastLine", {"Date created", each if [Date created] > (DateTime.FixedLocalNow()) then Date.From(DateTime.FixedLocalNow()) else [Date created], type date})

 

Yours @Jimmy801 

 

= Table.TransformColumns(#"LastLine", {"Date created", each if [Date created] > (DateTime.FixedLocalNow()) then Date.From(DateTime.FixedLocalNow()) else [Date created], type date})

 

I replaced the "_" with my [column name]. 

 

Otherwise, my tablename is "SOURCE". I don't know if it was supposed to go somewhere in my synthax. 

 

Thanks

Don't replace the "_", it represents the row value of [Date Created].

 

If you insert the code exactly as @Jimmy801 posted after the #"LastLine", then it should work.

 

If it doesn't, can you post the whole query?

Well, I was being stuborn because I didn't knew that I could use the symbol "_" in a query (oups). 

 

It was my bad. Thank you @TheDataMustFlow for this comprehensive answer. 

Hello @NumeroENAP 

 

this is not my code. Check it out.. mine should work

 

JImmy

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.