Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
I have created a column to get the Max Date form a Date column in my table and now I want to create a new column to get the Previous Max Date.
I tried this to get the it:
Table.AddColumn(#"Changed Type10", "Prev Max Rate Date", each Date.From(List.Max(#"Changed Type10"[Rate Start Date]))<(#"Changed Type10"[Max Rate Date]))
Here's what I used to get Max Date:
Table.AddColumn(#"Added Custom3", "Max Rate Date", each Date.From(List.Max(#"Added Custom3"[Rate Start Date])))
What steps do I need to take after adding my Max Date column to get Prev Max date?
Thanks
Solved! Go to Solution.
Hi @atowriss99
Are you trying to create a custom column to get the second maximum? If so, you can try the following:
My sample:
Max date:
The second Max date:
List.Sort(#"Addcolumn"[Date], Order.Descending){1}
Result:
Here is the whole M function in Advanced Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ30TcyMDJRitWJVjLVNwNxjMEcC31DM4SUmb6hEULOFIUHVGmI4JnrG5ogeJYopqCaCTQDYgyQGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Addcolumn" = Table.AddColumn(#"Changed Type", "Max Rate Date", each Date.From(List.Max(#"Changed Type"[Date]))),
#"Added Custom" = Table.AddColumn(#"Addcolumn", "Previous Max Date", each List.Sort(#"Addcolumn"[Date], Order.Descending){1}, type date)
in
#"Added Custom"
If I've misunderstood you, please provide detailed sample data and the results you are hoping for: How to provide sample data in the Power BI Forum - Microsoft Fabric Community . Or show it as a screenshot or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.
Best Regards,
Yulia Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @atowriss99
Are you trying to create a custom column to get the second maximum? If so, you can try the following:
My sample:
Max date:
The second Max date:
List.Sort(#"Addcolumn"[Date], Order.Descending){1}
Result:
Here is the whole M function in Advanced Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ30TcyMDJRitWJVjLVNwNxjMEcC31DM4SUmb6hEULOFIUHVGmI4JnrG5ogeJYopqCaCTQDYgyQGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Addcolumn" = Table.AddColumn(#"Changed Type", "Max Rate Date", each Date.From(List.Max(#"Changed Type"[Date]))),
#"Added Custom" = Table.AddColumn(#"Addcolumn", "Previous Max Date", each List.Sort(#"Addcolumn"[Date], Order.Descending){1}, type date)
in
#"Added Custom"
If I've misunderstood you, please provide detailed sample data and the results you are hoping for: How to provide sample data in the Power BI Forum - Microsoft Fabric Community . Or show it as a screenshot or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.
Best Regards,
Yulia Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.