The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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...
Solved! Go to Solution.
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.
2. Create a custom column using the formula.
=List.Max(#"Changed Type"[Date])
3. You will get the expected result as follows.
Best Regards,
Angelia
This has been answered but the steps are not fully clear, for the New Power BI User I will break down the solution:
There currently is NO data type of "List", just make sure you have the column as Data or Number.
Here is where the confusing part comes in as the actual "List.Max()" function isnt complete in syntax you either have to know exactly how to code it or you need to make an adjustment in Advanced Editor Section to manualy type in the previous Query Step Name as "Table" reference.
I create a new Column I type the following in the column formual page "=List.Max({INSERT COLUMN NAME})" Add Column
THEN I go into Advanced Editor and Copy the Query Name from the prior step in the front of my INSERTED COLUMN NAME.
BEFORE:
#"Changed column type" = Table.TransformColumnTypes(Navigation, {{"ci_item_time", type date}}), #"Added custom" = Table.AddColumn(#"Changed column type", "Custom", each List.Max([ci_item_time]))
AFTER:
#"Changed column type" = Table.TransformColumnTypes(Navigation, {{"ci_item_time", type date}}),
#"Added custom" = Table.AddColumn(#"Changed column type", "Custom", each List.Max(#"Changed column type"[ci_item_time]))
NOW if you knew what your prior Query Step name was you could have manually coded this into the New Column Formula statement like List.Max(#"Changed column type"[ci_item_time]) I hope this clears up any confusion on this Topic.
E I L O O P
Old thread, but this is/was available on the Ribbon also: Transform tab > Date & Time Column section > Date > Latest
It generates the same M as in this thread:
= List.Max(Source[Date])
Thanks for answer! Probably my question was not fully described... What I want to get is MAX DATE for particular customer number and have it sorted from list.
Example:
customer | date |
1 | 18.06.2019 |
1 | 19.06.2019 |
1 | 20.06.2019 |
2 | 18.06.2019 |
2 | 19.06.2019 |
3 | 20.06.2019 |
Thanks!
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.
So I added a column with this formula:
=List.Max([Date Column])
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.
2. Create a custom column using the formula.
=List.Max(#"Changed Type"[Date])
3. You will get the expected result as follows.
Best Regards,
Angelia
How do i do this with an Column of type Int? There is no such thing as a list item in the dropdown i can transform this too.
Hi @v-huizhn-msft!
But how to get max date for each Customer number if it have few of them?
Thanks
Kaspars
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.
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])
your column type is List? That function is to find max in a list or use groupby function to get maximum date.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
78 | |
70 | |
52 | |
50 |
User | Count |
---|---|
120 | |
120 | |
76 | |
62 | |
61 |