Forum Discussion

ebp2022's avatar
ebp2022
Frequent Visitor
3 years ago
Solved

Data Modeling for Manager-Supervisor-Employee Results Hierarchy

Good day!  Below is an illustration of my tables and the desired result.   Goal: To see performance results by Manager, Supervisor, Employee dynamically in different measures and different date ran...
  • DataInsights's avatar
    3 years ago

    ebp2022,

     

    Try this solution.

     

    Create a table of distinct Employee ID in either Power Query or DAX. This is a bridge table between EmployeeHierarchy and each fact table.

     

     

    Create measures:

     

    Sales = 
    VAR vDate =
        TREATAS ( VALUES ( EmployeeHierarchy[Date] ), FactSales[Date] )
    VAR vResult =
        CALCULATE (
            SUM ( FactSales[Sales] ),
            CROSSFILTER ( EmployeeHierarchy[Employee ID], DistinctEmployee[Employee ID], BOTH ),
            vDate
        )
    RETURN
        vResult
    Complaints = 
    VAR vDate =
        TREATAS ( VALUES ( EmployeeHierarchy[Date] ), FactComplaint[Date] )
    VAR vResult =
        CALCULATE (
            SUM ( FactComplaint[Complaints] ),
            CROSSFILTER ( EmployeeHierarchy[Employee ID], DistinctEmployee[Employee ID], BOTH ),
            vDate
        )
    RETURN
        vResult
    Satisfaction Score = 
    VAR vDate =
        TREATAS ( VALUES ( EmployeeHierarchy[Date] ), FactSatisfactionScore[Date] )
    VAR vResult =
        CALCULATE (
            MAX ( FactSatisfactionScore[Satisfaction Score] ),
            CROSSFILTER ( EmployeeHierarchy[Employee ID], DistinctEmployee[Employee ID], BOTH ),
            vDate
        )
    RETURN
        vResult

     

    Add EmployeeHierarchy fields and the measures to a visual: