GROUP BY and COUNTIFS
Hi All,
Thanks in advance for the assistance - I am extremely new to Power Query, and I've been looking for the last 3 hours for a solution to my issue. The majority of posts I've found remotely close to this use GROUP BY and COUNTIF, but I really need to use COUNTIFS.
My source data looks like this (there's more data but it's proprietary and not really important to my question) -
| Test Scenario ID | Test Scenario Type | Test Case Status | Test Case Result |
| MP1.01 | Functionality | Not Started | |
| MP1.02 | Functionality | Not Started | |
| MP1.03 | Functionality | Not Started | |
| MP2.01 | Content | Complete | Pass |
| MP2.02 | Content | Complete | Pass |
| MP2.03 | Content | Complete | Pass |
| MP2.04 | Functionality | Complete | Pass |
| MP2.05 | Functionality | Complete | Pass |
| MP2.06 | Functionality | Complete | Pass |
| MP2.07 | Functionality | Complete | Pass |
| MP2.08 | Functionality | Complete | Pass |
| MP3.01 | Functionality | Complete | Pass |
| MP3.02 | Functionality | Complete | Pass |
| MP4.01 | Content | Complete | Pass |
| MP4.02 | Content | Complete | Pass |
| MP4.03 | Content | Complete | Pass |
| MP4.04 | Content | Complete | Pass |
| MP5.01 | Functionality | Complete | Pass |
| MP6.01 | Functionality | Complete | Pass |
| MP7.01 | Functionality | Complete | Pass |
| MP8.01 | Functionality | Complete | Pass |
| MP8.02 | Pricing | Complete | Pass |
| MP8.03 | Pricing | Complete | Pass |
| MP8.04 | Pricing | Complete | Pass |
| MP8.05 | Pricing | Complete | Pass |
| MP8.06 | Pricing | Complete | Pass |
I need to transform this into a new table -
| Test Type | Total | Not Started | Complete | Pass | Fail |
| Functionality | 14 | 3 | 11 | 11 | 0 |
| Content | 7 | 0 | 7 | 7 | 0 |
| Pricing | 5 | 0 | 5 | 5 | 0 |
When I try to use Group By, I can no longer reference the source data to create the additional columns. I also can't seem to figure out the conditional column structure/formulas to refer back to the original source data for the COUNTIFS structure (eg. COUNTIFS type = Functionality, Status = Not Started). Can anyone point me in the right direction to figure this out? THANK YOU!
You can write the aggregations for the Table.Group function in the Advanced Editor manually.
let //Change next line to reflect actual data source Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{ {"Test Scenario ID", type text}, {"Test Scenario Type", type text}, {"Test Case Status", type text}, {"Test Case Result", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Test Scenario Type"}, { {"Total", each Table.RowCount(_), Int64.Type}, {"Not Started", (t)=> List.Count(List.Select(t[Test Case Status], each _ = "Not Started")), Int64.Type}, {"Complete", (t)=>List.Count(List.Select(t[Test Case Status], each _ = "Complete")), Int64.Type}, {"Pass", (t)=>List.Count(List.Select(t[Test Case Result], each _ = "Pass")), Int64.Type}, {"Fail", (t)=>List.Count(List.Select(t[Test Case Result], each _ = "Fail")), Int64.Type} }) in #"Grouped Rows"Your Data
Results