March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi folks,
I want to analyse a table with Power Query of dates of work packages for different projects. I need to create a new table containing a list of all projects and their finish date. A project is considered finished when all work packages are finished, the finished date is the latest date of the work packages. Different projects have varying numbers of work packages.
The input looks like this:
Project ID | Workpackage | Workpackage finished |
P1 | A | 01.08.2023 |
P1 | B | 02.08.2023 |
P1 | C | 03.08.2023 |
P2 | A | 02.07.2023 |
P2 | B | 12.07.2023 |
P3 | A | |
P3 | B | 02.08.2023 |
P3 | C | 04.08.2023 |
P3 | D |
The output I want to generate should look like this:
Project ID | Project finished |
P1 | 03.08.2023 |
P2 | 12.07.2023 |
P3 |
So the logic is: For each Project ID, check if all work packages are finished, if yes find and return latest date, else return null.
I would really really appreciate any help. I think I could code this in C but I'm totally lost in Power Query M.
Thank you!
Simon
Way more concise to use DAX
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
@Simon_- Please check this out, copy the M code in your advanced editor, use the same field name. Let me know if this works. If this fix your problem, please tick this a solution and a thumps up.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjBU0lFyBGIDQz0DCz0jAyNjpVgdqLgTSNwIU9wZJG6MKm4EMweo3hxNHGSOIZq4MVS9AoKLzTpjmHUmmOIuQKwUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project ID" = _t, Workpackage = _t, #"Workpackage finished" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Project ID", type text}, {"Workpackage", type text}, {"Workpackage finished", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Project ID"}, {{"MaxDate", each List.Max([Workpackage finished]), type nullable date}})
in
#"Grouped Rows"
Sample code below
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjBU0lFyBGIjAyNjXQMLXQNDpVgdqLgTsrgRQtwZWdwYIm6EYo45XL0RijnmuoZQcWOoegQPm23G6LaZIMRdwLpjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project ID" = _t, Workpackage = _t, #"Workpackage finished" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Project ID", type text}, {"Workpackage", type text}, {"Workpackage finished", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Project ID"}, {{"Project finished", each if List.Contains(_[Workpackage finished],null) then null else List.Max(_[Workpackage finished])}})[[Project ID], [Project finished]]
in
#"Grouped Rows"
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
16 | |
13 | |
12 | |
9 |
User | Count |
---|---|
36 | |
31 | |
20 | |
19 | |
17 |