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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
GGG123
Regular Visitor

Issue with List.Max ([Date]) in power query

This formula

 

   Date.From(List.Max(Table.Column(#"Reordered Columns", [Date]))) - Date.From([Date])

 

is returning this error Expression.

 

   Error:

   We cannot convert the value #date(2024, 1, 15) to type Text.
   Details:
   Value=15/01/2024
   Type=[Type]

 

The column Date in power query is Type--> Date

 

I'm trying to get the latest date from the column Date and return for each date in the column the difference between the latest date and the date in each row.

 

How do I make this work?

1 ACCEPTED SOLUTION

I finally worked it out. All I did is to go at the beginning of the code and Filtered Out "Undeposited Items" which was mentioned in the error I was getting 'DataFormat.Error: We couldn't parse the input provided as a Date'.

The thing that I couldnt understand is that when looking at the Column Profile, everything showed 0 Error and the count seemed to be all in order. 

Thanks for your help anyway!

View solution in original post

8 REPLIES 8
GGG123
Regular Visitor

 

Now I'm getting this error:

   DataFormat.Error: We couldn't parse the input provided as a Dat

It's so weird because until last month I never had problems with this Power Query model. 

Also, when I use the formula List.Max to find the latest date on a different paper, it works fine. 

I tried to changed the Date as Locale and play around a bit but still the same error.

Hello @ ,

If my post helped you, please give me a 👍kudos and mark this post with Accept as Solution.


Do you perhaps have a screenshot of your data table or an excerpt of the data or the M-Code? It looks like your column is not correctly defined as a Date data type. In the following screenshot I have added my solution to some test data.

 

ManuelBolz_0-1718175603877.png


Best regards from Germany
Manuel Bolz


🟦Follow me on LinkedIn
🟨How to Get Your Question Answered Quickly
🟩Fabric Community Conference
🟪My Solutions on Github

Thnaks for all your answers. However, I ve tried that too and the data seems fine. 

See below:

GGG123_0-1718175988908.png

 

GGG123_2-1718176477672.png

 

I also tried to look for the 'Undeposited Items' mentioned in the Error but the column seems to be having only dates, as it should.

Hello @GGG123,

If my post helped you, please give me a 👍kudos and mark this post with Accept as Solution.

Here is my slightly adapted code. I hope this helps. Here you have to adapt the "Source" step to your code again.

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc1LDsAgCEXRvTA2kY+KezHufxuFkjY2KZM3ObmwFlCvSJWRGxQgVVsW2OVfWir9FpZTpvhKKtEYtAdYyHZyvNGK/ZXBnmAkeIp6QxmMAPqA39IM2J7sCw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Page = _t, Line = _t]),
    Type = Table.TransformColumnTypes(Source,{{"Date", type date}}),

    LatestDate = List.Max(Table.Column(Type, "Date")),
    AddedDateDifference = Table.AddColumn(Type, "Date Difference", each Duration.Days(LatestDate - [Date]), Int64.Type)
in
    AddedDateDifference

 

 

 

ManuelBolz_1-1718176969715.png



Best regards from Germany
Manuel Bolz


🟦Follow me on LinkedIn
🟨How to Get Your Question Answered Quickly
🟩Fabric Community Conference
🟪My Solutions on Github

I finally worked it out. All I did is to go at the beginning of the code and Filtered Out "Undeposited Items" which was mentioned in the error I was getting 'DataFormat.Error: We couldn't parse the input provided as a Date'.

The thing that I couldnt understand is that when looking at the Column Profile, everything showed 0 Error and the count seemed to be all in order. 

Thanks for your help anyway!

Im not sure how to fit your code into mine.

 

Here's mine.

let
Source = Excel.Workbook(File.Contents("\\accnzrep01\B2B\Bank\Bank Reconciliation Report\Bank Reconciliation Report Data Export (Month End).xls"), null, true),
Sheet2 = Source{[Name="Sheet1"]}[Data],
#"Removed Top Rows" = Table.Skip(Sheet2,4),
#"Added Conditional Column" = Table.AddColumn(#"Removed Top Rows", "Txn Type", each if [Column1] = "Unreconciled Statement Items" then "Unreconciled Statement Items" else if [Column1] = "Unreconciled GL Items" then "Unreconciled GL Items" else null),
#"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "GL String", each if [Column1] = "Code:" then [Column2] else null),
#"Filled Down" = Table.FillDown(#"Added Conditional Column1",{"Txn Type", "GL String"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Down", each [Column1] <> null and [Column1] <> "Date" and [Column1] <> "Code:" and [Column1] <> "Unreconciled Statement Items" and [Column1] <> "Unreconciled GL Items" and [Column1] <> "BankRecRep.rpt"),
#"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"Column3", "Page"}, {"Column6", "Line"}, {"Column10", "Type"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Column1", type date}}),
#"Renamed Columns1" = Table.RenameColumns(#"Changed Type",{{"Column1", "Date"}, {"Column12", "Reference"}, {"Column15", "Details"}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns1",{{"Column23", Currency.Type}}),
#"Removed Other Columns" = Table.SelectColumns(#"Changed Type1",{"Date", "Page", "Line", "Type", "Reference", "Details", "Column23", "Txn Type", "GL String"}),
#"Renamed Columns2" = Table.RenameColumns(#"Removed Other Columns",{{"Column23", "Amount"}}),
#"Uppercased Text" = Table.TransformColumns(#"Renamed Columns2",{{"Reference", Text.Upper, type text}, {"Details", Text.Upper, type text}}),
#"Reordered Columns" = Table.ReorderColumns(#"Uppercased Text",{"Txn Type", "GL String", "Date", "Page", "Line", "Type", "Reference", "Details", "Amount"})
in
#"Reordered Columns"

 

 

Up until this point everything works fine. Are you able to fit your code into mine so that I only need to paste it in the advanced editor? 

Thanks!

ManuelBolz
Super User
Super User

Hello @GGG123  ,

If my post helped you, please give me a 👍kudos and mark this post with Accept as Solution.

Try this solution.

 

let
    #"Reordered Columns" = YOURCODE
    LatestDate = List.Max(Table.Column(#"Reordered Columns", "Date")),
    AddedDateDifference = Table.AddColumn(Source, "Date Difference", each Duration.Days(LatestDate - [Date]), Int64.Type)
in
    AddedDateDifference

 



Best regards from Germany
Manuel Bolz


🟦Follow me on LinkedIn
🟨How to Get Your Question Answered Quickly
🟩Fabric Community Conference
🟪My Solutions on Github

Joe_Barry
Super User
Super User

Hi @GGG123 

 

This video will help you create the MaxDate in a new column. https://www.youtube.com/watch?v=hidJ5T_DYQ0

 

You can then create a custom column

 

 

[NewColumn] - [Date]

 

 

 this will return a duration value

 

Hope this helps




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

Proud to be a Super User!





Learn about the Star Schema, it will solve many issues in Power BI!

Date tables help! Learn more



LinkedIn
Let's connect on LinkedIn


Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.