Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Employee Report filtered by Manager

I have an employee table where along with few information about the employee, I also have their manager information.

EmployeeNameEmployeeIDManagerHierarchyFTEDepartmentCountry
Stva3651_3651_34640_199891TSweden
Evka24243_24243_886_199890.75TSweden
Siva32136_32136_886_199891TSweden
Alva18509_18509_34640_199890.75TSweden
Jaik13390_13390_20809_199890.75TSweden
Ever20242_20242_20809_199890.75TSweden
Maat42163_42163_199891ASweden
Datz36057_36057_20809_199890.5TSweden
Juon31146_31146_20809_199891TSweden
Maov14773_14773_34640_199891TSweden
Ivev10512_10512_34640_199891SSweden
Viey15423_15423_199891ASweden
Kaov5673_5673_34640_199890.25SSweden
Clte43563_43563_199891AGreat Britain
Arvs19989_199891AGreat Britain
Tsov34640_34640_199891SGreat Britain
Stov5072_5072_34640_199891SGreat Britain
Ench20809_20809_199891AGreat Britain
Tilf886_886_199891AItaly

 

 

I want to give user the choice of manager and the user should be able to see aggregated data about the employee e.g. Total FTE for that team and line by line information.

For example, Mr. Tilf has 2 employees reporting to him: Evka and Siva, so selecting Mr Tilf will give me total FTE = 2.75

Mr Tilf 1
Mr Evka 0.75
Mr Siva 1


Can anyone help me please ?

7 Replies

  • olgad's avatar
    olgad
    Icon for Resident Rockstar rankResident Rockstar

    Hi Saniat,
    here is the result:

    First make changes in  power query:

    let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZNPS8QwEMW/ivS8SP626XHVIqvsqYuXUkrQiGFLF7qxsn56M5MitKlrDyWPJD/ezJumqpLSDTrZJDyV1C8NrA0XqSANzXOV+z3YP/iv/DJvpkvqTZUUwxEgJpjgQKFolEp/IXKbyZgrbTBjlKfoBmLCLZhtW4SokgRuNChmNS7bPWl7BJLznCAJomFEef46WQymhwaJ7wwbBLGK3Gvt/I5gNMVoUEza206BB+2+cQBEZmECXkRWS919njoAKRUhTBAzcCHOvT4NcCKyDAtE8f/Id4NBjEiKiaBYwMop9mLNBU6kYMENxLU4nkN5Mg3VwRrNmsnY6L51BnLncswdRGT02Bvtbu5667Qd/65+OMOF8eIK4nDGCrEozH0xg5grXeiMZBggrKvZonv9wP9RhTcQT/mPWm377g/8CwNq/tCA2TndXpK6/gE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [EmployeeName = _t, EmployeeID = _t, ManagerHierarchy = _t, FTE = _t, Department = _t, Country = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"EmployeeName", type text}, {"EmployeeID", Int64.Type}, {"ManagerHierarchy", type text}, {"FTE", type number}, {"Department", type text}, {"Country", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","_","|",Replacer.ReplaceText,{"ManagerHierarchy"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Replaced Value", "ManagerHierarchy", Splitter.SplitTextByEachDelimiter({"|"}, QuoteStyle.Csv, false), {"ManagerHierarchy.1", "ManagerHierarchy.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"ManagerHierarchy.1", type text}, {"ManagerHierarchy.2", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"ManagerHierarchy.1"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"ManagerHierarchy.2", "ManagerHierarchy"}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Renamed Columns", "ManagerHierarchy", "ManagerHierarchy - Copy"),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Duplicated Column", "ManagerHierarchy", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"ManagerHierarchy.1", "ManagerHierarchy.2", "ManagerHierarchy.3"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"ManagerHierarchy.1", Int64.Type}, {"ManagerHierarchy.2", Int64.Type}, {"ManagerHierarchy.3", Int64.Type}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Changed Type2",{"ManagerHierarchy.1"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns1",{{"ManagerHierarchy.2", "ParentEmployeeID"}}),
    #"Removed Columns2" = Table.RemoveColumns(#"Renamed Columns1",{"ManagerHierarchy.3"}),
    #"Renamed Columns2" = Table.RenameColumns(#"Removed Columns2",{{"ManagerHierarchy - Copy", "ManagerHierarchy"}})
    in
    #"Renamed Columns2"
    from left to right

    Then ölets create 3 calculated columns. 

    Level = PATHLENGTH(emloyee[ManagerHierarchy])

    ManagerName = LOOKUPVALUE(emloyee[EmployeeName],emloyee[EmployeeID],emloyee[ParentEmployeeID])

    Team = IF(emloyee[Level]>2,LOOKUPVALUE(emloyee[EmployeeName],emloyee[EmployeeID],PATHITEM(emloyee[ManagerHierarchy],2,INTEGER)),emloyee[EmployeeName])

    Let me know if  you succeeded.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Very innovative solution !

      But the problem identified here is just a part of a bigger report, and I need to report these two measures (aggregate for the team and details of each employee) in multiple places, and unfortunately cannot use the full table (like your solution) each time.

  • olgad's avatar
    olgad
    Icon for Resident Rockstar rankResident Rockstar

    Innovative, give a kudo!:) What do you mean you cannot use the table, it is the data you provided, you said you have such a table. Where are you gonna take the info from then? Try to reformulate, i do lots of HR reports, may be i can help further.

     

    Wasnt this the result you needed?

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks olgad  !

      I will be reporting the figure 2.75 in many places, cannot really put the whole list everytime.

    • Anonymous's avatar
      Anonymous
      Not applicable

      It seems like if I have 20 measures, I need to integrate this complex calculation for ManagerHierarchy for each individual calculation. No way to use a filter which I can use in the filter pane.... am I right ?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    You can create a new table to filter the manager:

    Manager = var _countrows=ADDCOLUMNS('employee',"counts",COUNTROWS(FILTER('employee',CONTAINSSTRING([ManagerHierarchy],EARLIER('employee'[EmployeeID])))))
    return SUMMARIZE(FILTER(_countrows,[counts]>1),[EmployeeName],[EmployeeID])
    

    Then put the Employee column in Manager table to the slicer.

     And create a measure in employee table:

    Display = IF(ISFILTERED(Manager[EmployeeName]),CALCULATE(SUM('employee'[FTE]),FILTER('employee',CONTAINSSTRING([ManagerHierarchy],MAX(Manager[EmployeeID])))),SUM(employee[FTE]))

    Output:

     

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.