cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ovetteabejuela Established Member
Established Member

Power Query: List.Max doesn't work on Date

Hi,

 

Need some help. Supposedly List.Max should work on Dates right? Like List.Max([Date Column]).

 

I have a column of Date type and I tried to Add Column with the formula List.Max([Date Column]) but it's giving me this error:

 

Expression.Error: We cannot convert the value #date(2017, 10, 31) to type List.
Details:
Value=10/31/2017
Type=Type

 

So I might be missing something here...

1 ACCEPTED SOLUTION

Accepted Solutions
v-huizhn-msft Super Contributor
Super Contributor

Re: Power Query: List.Max doesn't work on Date

Hi @ovetteabejuela,

As I tested, you need to create the date column as a list, then use it in List.Max(). I have the following sample table.

1.PNG

2. Create a custom column using the formula.

=List.Max(#"Changed Type"[Date])

2.PNG

3. You will get the expected result as follows.

3.PNG

Best Regards,
Angelia

7 REPLIES 7
Super User
Super User

Re: Power Query: List.Max doesn't work on Date

your column type is List? That function is to find max in a list or use groupby function to get maximum date.




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

Proud to be a Datanaut! Connect with me on Linkedin






Super User
Super User

Re: Power Query: List.Max doesn't work on Date

Whats the context of the power query line of code?  Are you passing a column or list type to the function?  The error message reads like you have passed a since value of type Date.


   

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

Proud to be a Datanaut!


   


ovetteabejuela Established Member
Established Member

Re: Power Query: List.Max doesn't work on Date

So I added a column with this formula:

 

=List.Max([Date Column])

Super User
Super User

Re: Power Query: List.Max doesn't work on Date

So when you look at the actual code in the Advanced Editor, does this come after an 'each' statement?  If so, you are passing a single value into that statement.


   

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

Proud to be a Datanaut!


   


Super User
Super User

Re: Power Query: List.Max doesn't work on Date

The column name must be preceded by the table name, which can be either the name of another query or the name of another step in the current query.

 

=List.Max(Table[Date Column])
Specializing in Power Query Formula Language (M)
v-huizhn-msft Super Contributor
Super Contributor

Re: Power Query: List.Max doesn't work on Date

Hi @ovetteabejuela,

As I tested, you need to create the date column as a list, then use it in List.Max(). I have the following sample table.

1.PNG

2. Create a custom column using the formula.

=List.Max(#"Changed Type"[Date])

2.PNG

3. You will get the expected result as follows.

3.PNG

Best Regards,
Angelia

KasparsT Visitor
Visitor

Re: Power Query: List.Max doesn't work on Date

Hi @v-huizhn-msft!

But how to get max date for each Customer number if it have few of them?

Thanks 

 

Kaspars