Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Need help with DAX

Hi,   I'm trying to write a DAX query for weekly rolling avg per emp, however, I'm unable to get the desired results in my report. I've got Week_Key, Date_Key, Emp_ID, ActualWorkingHours, Avg_Ho...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    I read your requirements and I do some changes with my DAX code.

    Column =
    VAR _A =
        SUMX (
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[EmpID] = EARLIER ( 'Table'[EmpID] )
                    && 'Table'[week_Key] <= EARLIER ( 'Table'[week_Key] )
            ),
            'Table'[Working hours on that week]
        )
            / SUMX (
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    'Table'[EmpID] = EARLIER ( 'Table'[EmpID] )
                        && 'Table'[week_Key] <= EARLIER ( 'Table'[week_Key] )
                ),
                'Table'[Count of week (1 if no absences)]
            )
    RETURN
        IF ( 'Table'[Count of week (1 if no absences)] = 0, 0, _A )

    Then you will get what you want.

     

     

     

    Best Regards

    Yilong Zhou

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