Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
How can I add a custom column to a table with the value which is the minimum date from a field in another table?
Thank You,
Michael
Solved! Go to Solution.
Hi @MikeSolvesBI ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) Paste the following code into Advanced Editor.
Table2:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1ACGlWB0cXFNdAzMkrrmugYVSbCwA", 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}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.Group(#"Changed Type", {}, {{"Min_date", each List.Min([Date]), type nullable date}})),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Min_date"}, {"Min_date"})
in
#"Expanded Custom"
Table:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyagkkzpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each #"Table2"[Min_date]{0})
in
#"Added Custom"
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @MikeSolvesBI ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) Paste the following code into Advanced Editor.
Table2:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1ACGlWB0cXFNdAzMkrrmugYVSbCwA", 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}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.Group(#"Changed Type", {}, {{"Min_date", each List.Min([Date]), type nullable date}})),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Min_date"}, {"Min_date"})
in
#"Expanded Custom"
Table:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyagkkzpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each #"Table2"[Min_date]{0})
in
#"Added Custom"
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
73 | |
70 | |
38 | |
24 | |
23 |
User | Count |
---|---|
96 | |
94 | |
50 | |
42 | |
40 |