Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Wazza
New Member

Tracker - Way of working : Work from home Versus Office - Employee % over the years

Hi there, 

 

I built a report to track the percentage of people working from home (WFH) versus from the office (WFO). 

 

We are tracking it in an Excel file, where employees state when they want to come to the office. 

The files from different departments are then all combined and tracked in powerBI to have a global picture. 
The issue is that the file is quite "long" as it's tracking for 2020, 2021, and a forecast for the coming months. 

Excel file: 

Employee ID       01/01/2020   01/02/2020     ....     01/01/2021    01/02/2021   ....   01/01/2022     01/02/2022
E01      WFH      WFH       WFH      WFH       WFH      WFH
E02      WFH      WFO       WFH      WFH       WFO      WFO
E03      WFO      WFH       WFO      WFO       WFH      WFH
E04      WFO      WFO       WFO      WFO       WFO      WFO

 

So when I unpivot the table to get something that I can manage in power BI, it becomes: 

E01

01/01/2020     WFH
E0101/02/2020     WFH
E01... 
E0101/01/2021     WFH
E0101/02/2021     WFH
...  
E0201/01/2020     WFO
E0201/02/2020       WFH
E02... 
E02  01/01/2021  WFH

 

365 days a year * 2.5 years * 30 employees.. = a lot of rows! 

 

Any simpler way of doing it to have a more responsive file and a more elegant way of tracking it? 

For example, would it make sense to "regroup employees" per day such as: 

Date   WFH   WFO
01/01/2020  E01, E02       E03,E04
01/02/2020     E01, E03  E02, E04    
.........
1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Wazza ,

You can try this query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjUwVNJRCnfzIEDG6oDUGiGJ+WOo8oeSELXGGKr8seiDqDXBkMdGxsYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Employee ID" = _t, #"01/01/2020" = _t, #"01/02/2020" = _t, #"01/01/2021" = _t, #"01/02/2021" = _t, #"01/01/2022" = _t, #"01/02/2022" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee ID", type text}, {"01/01/2020", type text}, {"01/02/2020", type text}, {"01/01/2021", type text}, {"01/02/2021", type text}, {"01/01/2022", type text}, {"01/02/2022", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Employee ID"}, "Attribute", "Value"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Attribute", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type1", {"Attribute"}, {{"Data", each _, type table [Employee ID=nullable text, Attribute=nullable date, Value=text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "WFH", each Table.SelectRows([Data], each [Value] = "WFH")[Employee ID]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "WFO", each Table.SelectRows([Data], each [Value] = "WFO")[Employee ID]),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom1", {"WFH", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Extracted Values1" = Table.TransformColumns(#"Extracted Values", {"WFO", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values1",{"Data"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Attribute", "Date"}})
in
    #"Renamed Columns"

vyingjl_0-1632894570607.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

6 REPLIES 6
v-yingjl
Community Support
Community Support

Hi @Wazza ,

You can try this query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjUwVNJRCnfzIEDG6oDUGiGJ+WOo8oeSELXGGKr8seiDqDXBkMdGxsYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Employee ID" = _t, #"01/01/2020" = _t, #"01/02/2020" = _t, #"01/01/2021" = _t, #"01/02/2021" = _t, #"01/01/2022" = _t, #"01/02/2022" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee ID", type text}, {"01/01/2020", type text}, {"01/02/2020", type text}, {"01/01/2021", type text}, {"01/02/2021", type text}, {"01/01/2022", type text}, {"01/02/2022", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Employee ID"}, "Attribute", "Value"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Attribute", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type1", {"Attribute"}, {{"Data", each _, type table [Employee ID=nullable text, Attribute=nullable date, Value=text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "WFH", each Table.SelectRows([Data], each [Value] = "WFH")[Employee ID]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "WFO", each Table.SelectRows([Data], each [Value] = "WFO")[Employee ID]),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom1", {"WFH", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Extracted Values1" = Table.TransformColumns(#"Extracted Values", {"WFO", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values1",{"Data"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Attribute", "Date"}})
in
    #"Renamed Columns"

vyingjl_0-1632894570607.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

I did the unpivot in Excel as a quick workaround but I will use this feature for the next file that I am building. 
Thanks 

PhilipTreacy
Super User
Super User

Hi @Wazza 

You should structure the data into a tabular format e.g.

tabular-format.png

No need to unpivot with this.  It's in the correct format for use in PBI/Power Pivot etc and makes reporting much easier.

Loading this data into PBI will comprress it so if your concern is file size, this structure is better.  You can't really get around the file/data being 'long', you have to track whatever data you need.

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


thank you. 
I used Power Query in Excel to convert the file. 
This way, the "processing work" is done beforehand and PowerBI just has to display it 🙂 

amitchandak
Super User
Super User

@Wazza , if you want that in visual, you can use concatenatex

create a measure and use that in matrix with date on row and work from on Column and measure in values

 

concatenatex(Table, Table[Name])

Hi, 
Thanks for your answer. 


Regarding the other format, it was just an idea that I had. 

If the only solution is to unpivot the table and have everything like currently, then ok. 
But if there is a simpler way, I am curious about it. 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.