Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I have a data transformation that I would like to make in PowerQuery (preferred output is table rather than pivot table) but can't quite figure it out.
To use a simplified example, consider this table (sorted by position):
I would like to use PowerQuery to add a column that shows the DISTINCT COUNT OF SUPERVISOR PER POSITION.
So, the end result would be this:
Here's the example table: Example Data
Thanks in advance,
- Kurt
Solved! Go to Solution.
Try this
Please see your file attached as well
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"employee #", Int64.Type}, {"employee name", type text}, {"position", type text}, {"supervisor", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"position"}, {{"AllRows", each _, type table}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "DistinctCount", each List.Count(List.Distinct([AllRows][supervisor]))), #"Expanded AllRows" = Table.ExpandTableColumn(#"Added Custom", "AllRows", {"employee #", "employee name", "supervisor"}, {"employee #", "employee name", "supervisor"}) in #"Expanded AllRows"
Try this
Please see your file attached as well
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"employee #", Int64.Type}, {"employee name", type text}, {"position", type text}, {"supervisor", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"position"}, {{"AllRows", each _, type table}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "DistinctCount", each List.Count(List.Distinct([AllRows][supervisor]))), #"Expanded AllRows" = Table.ExpandTableColumn(#"Added Custom", "AllRows", {"employee #", "employee name", "supervisor"}, {"employee #", "employee name", "supervisor"}) in #"Expanded AllRows"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
95 | |
77 | |
68 | |
54 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |