Forum Discussion
staffing levels cumulative data
I have some staffing level data which looks like this:
| emp ID | FTE Month 01 | FTE Month 02 | FTE Month 03 | FTE Month 04 | FTE Month 05 | FTE Month 06 | FTE Month 07 | FTE Month 08 | FTE Month 09 | FTE Month 10 | FTE Month 11 | FTE Month 12 |
| 01 | 0 | 0 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 | 40 |
| 02 | 0 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| 03 | 53 | 53 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 04 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| 05 | 0 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| 06 | 0 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
| 07 | 75 | 75 | 75 | 75 | 75 | 75 | 0 | 0 | 0 | 0 | 0 | 0 |
| 08 | 0 | 0 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 | 100 |
noting that, for example, row 1 indicates somebody starting in two months, and row 3 indicates somebody leaving in two months.
I need to summarise it so that I have total FTE by month, for example:
| Mar-26 | Apr-26 | May-26 | Jun-26 | Jul-26 | Aug-26 | Sep-26 | Oct-26 | Nov-26 | Dec-26 | Jan-27 | Feb-27 |
| 228 | 528 | 615 | 615 | 615 | 615 | 540 | 540 | 540 | 540 | 540 | 540 |
so I can put it on a chart.
The problems are twofold as far as I can see:
1) the same FTE can appear in multiple columns so I am at risk of double counting;
2) there are other variables which I would really like to put in slicers, so I can't just summarise.
How do I do it?
Hi AndrewPF , To get the desired results you need to unpivot your data from columns to rows .
Sample data:
PQ:let Source = base, Unpivoted = Table.UnpivotOtherColumns( Source, {"Emp ID", "Department", "Role", "Location"}, "MonthNum", "FTE" ), CleanedMonth = Table.ReplaceValue( Unpivoted, "FTE Month ", "", Replacer.ReplaceText, {"MonthNum"} ), MonthAsInt = Table.TransformColumnTypes( CleanedMonth, {{"MonthNum", Int64.Type}} ), CalendarMonth = Table.AddColumn( MonthAsInt, "Calendar Month", each Date.AddMonths(#date(2026, 3, 1), [MonthNum] - 1), type date ), FilteredZeros = Table.SelectRows( CalendarMonth, each [FTE] <> 0 ), Reordered = Table.ReorderColumns( FilteredZeros, {"Emp ID", "Department", "Role", "Location", "MonthNum", "Calendar Month", "FTE"} ) in Reordered
OP:
PBIX:
FTE Calculation.pbix
Thanks
If you found this helpful, please consider giving it a kudo and marking it as the accepted solution — it goes a long way in helping others facing the same issue.
For more Power BI tips and discussions, let’s connect on LinkedIn:
https://www.linkedin.com/in/natarajan-manivasagan
Cheers!The standard approach in Power BI is to unpivot the data to bring it into usable format
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSs0tUPB0UdJRcgtxVfDNzyvJUDAwROUaoXKNUbkmqFxTVK4ZKtcclWuByrVE4RoaoHJRXWVopBSrE60EdqsBFJuQSIANMIJqNjSgjAQbBgobUzhhQBQGazShgguQ3GFKTU+ZUdMwUAowN8VH4AklCyQh8twBNgfKJIhiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t, Column7 = _t, Column8 = _t, Column9 = _t, Column10 = _t, Column11 = _t, Column12 = _t, Column13 = _t]), #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]), #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Promoted Headers", {"emp ID"}, "Attribute", "Value"), #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Value", Int64.Type}}) in #"Changed Type"How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the entire Source step with your own source.
From there the visual writes itself.
2 Replies
- Natarajan_MSuper User
Hi AndrewPF , To get the desired results you need to unpivot your data from columns to rows .
Sample data:
PQ:let Source = base, Unpivoted = Table.UnpivotOtherColumns( Source, {"Emp ID", "Department", "Role", "Location"}, "MonthNum", "FTE" ), CleanedMonth = Table.ReplaceValue( Unpivoted, "FTE Month ", "", Replacer.ReplaceText, {"MonthNum"} ), MonthAsInt = Table.TransformColumnTypes( CleanedMonth, {{"MonthNum", Int64.Type}} ), CalendarMonth = Table.AddColumn( MonthAsInt, "Calendar Month", each Date.AddMonths(#date(2026, 3, 1), [MonthNum] - 1), type date ), FilteredZeros = Table.SelectRows( CalendarMonth, each [FTE] <> 0 ), Reordered = Table.ReorderColumns( FilteredZeros, {"Emp ID", "Department", "Role", "Location", "MonthNum", "Calendar Month", "FTE"} ) in Reordered
OP:
PBIX:
FTE Calculation.pbix
Thanks
If you found this helpful, please consider giving it a kudo and marking it as the accepted solution — it goes a long way in helping others facing the same issue.
For more Power BI tips and discussions, let’s connect on LinkedIn:
https://www.linkedin.com/in/natarajan-manivasagan
Cheers! - lbendlinSuper User
The standard approach in Power BI is to unpivot the data to bring it into usable format
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSs0tUPB0UdJRcgtxVfDNzyvJUDAwROUaoXKNUbkmqFxTVK4ZKtcclWuByrVE4RoaoHJRXWVopBSrE60EdqsBFJuQSIANMIJqNjSgjAQbBgobUzhhQBQGazShgguQ3GFKTU+ZUdMwUAowN8VH4AklCyQh8twBNgfKJIhiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t, Column7 = _t, Column8 = _t, Column9 = _t, Column10 = _t, Column11 = _t, Column12 = _t, Column13 = _t]), #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]), #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Promoted Headers", {"emp ID"}, "Attribute", "Value"), #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Value", Int64.Type}}) in #"Changed Type"How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the entire Source step with your own source.
From there the visual writes itself.