Forum Discussion
KBD
1 year agoHelper III
Power Query under Power BI desktop create/add column for count of grouping
Hello: New to the PowerQuery/ Power BI world. I have a simple requirement.. I need to create a column which is the count of a two column grouping. In Power BI this works: weeklyNumMaint = ...
Power_BI9
1 year agoNew Member
To fix the cyclic error and achieve your goal in Power Query:
Group by Asset No and WeekYear:
- Use Group By in Power Query to group by Asset No and WeekYear, counting Work Orders per group.
Add Conditional Column:
- Add a conditional column for the flag:
- If WOs / Week = 1, then "One Work Order."
- Else "Multi Work Orders."
- Add a conditional column for the flag:
Power Query Code:
let
Source = YourTableNameHere,
GroupedData = Table.Group(Source, {"Asset No", "WeekYear"}, {{"WOs / Week", each Table.RowCount(_), Int64.Type}}),
AddFlagColumn = Table.AddColumn(GroupedData, "Flag", each if [WOs / Week] = 1 then "One Work Order" else "Multi Work Orders")
in
AddFlagColumn
This resolves the issue and adds the desired columns.