Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi,
I have a list of employee's FTE rate (work %) by month. I would like to calculate the average FTE rate (result should look like column D) per employee in power query. how should I write the power query formula?
Solved! Go to Solution.
An alternate approach using Group By is to add an aggregation for all rows:
1. Group By
2. Expand the All column and select Date Key and FTE rate:
3. Result:
Proud to be a Super User!
Hi @Jeanxyz ,
Base data:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc5LCgAgCEXRvTgO0teH9hLtfxs5zXw6EQ7C3VvUx6QIFFZ9/TRVOeUj+LlSafypcxqcZiDwQLyBKcQ+8D7wPiR95wI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"employee id" = _t, #"Date Key" = _t, #"FTE rate" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"employee id", Int64.Type}, {"Date Key", type date}, {"FTE rate", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"employee id"}, {{"average", each List.Average([FTE rate]), type nullable number}, {"TABLE1", each _, type table [employee id=nullable number, Date Key=nullable date, FTE rate=nullable number]}}),
#"Expanded TABLE1" = Table.ExpandTableColumn(#"Grouped Rows", "TABLE1", {"employee id", "Date Key", "FTE rate"}, {"TABLE1.employee id", "TABLE1.Date Key", "TABLE1.FTE rate"}),
#"Reordered Columns" = Table.ReorderColumns(#"Expanded TABLE1",{"employee id", "TABLE1.employee id", "TABLE1.Date Key", "TABLE1.FTE rate", "average"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Reordered Columns",{{"average", Int64.Type}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"employee id"})
in
#"Removed Columns"
Final get:
Wish it is helpful for you!
Best Regards
Lucien
Hi @Jeanxyz ,
Base data:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc5LCgAgCEXRvTgO0teH9hLtfxs5zXw6EQ7C3VvUx6QIFFZ9/TRVOeUj+LlSafypcxqcZiDwQLyBKcQ+8D7wPiR95wI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"employee id" = _t, #"Date Key" = _t, #"FTE rate" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"employee id", Int64.Type}, {"Date Key", type date}, {"FTE rate", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"employee id"}, {{"average", each List.Average([FTE rate]), type nullable number}, {"TABLE1", each _, type table [employee id=nullable number, Date Key=nullable date, FTE rate=nullable number]}}),
#"Expanded TABLE1" = Table.ExpandTableColumn(#"Grouped Rows", "TABLE1", {"employee id", "Date Key", "FTE rate"}, {"TABLE1.employee id", "TABLE1.Date Key", "TABLE1.FTE rate"}),
#"Reordered Columns" = Table.ReorderColumns(#"Expanded TABLE1",{"employee id", "TABLE1.employee id", "TABLE1.Date Key", "TABLE1.FTE rate", "average"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Reordered Columns",{{"average", Int64.Type}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"employee id"})
in
#"Removed Columns"
Final get:
Wish it is helpful for you!
Best Regards
Lucien
An alternate approach using Group By is to add an aggregation for all rows:
1. Group By
2. Expand the All column and select Date Key and FTE rate:
3. Result:
Proud to be a Super User!
@Jeanxyz , You might have create a table using group by avg and join it back with this table
Using group by option, Employee ID as Group and Avg of FTE rate , create a new table. Merge it back using merge option using employee id.
Also refer for part of the approch here
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.