Forum Discussion

harshad_barge's avatar
6 years ago
Solved

Help with DAX code

Hi, I have an excel output of a calculated DAX measure. The Calculated Pay (N) column is a sum of AUD Total Daily Earnings column, grouped by the Applicable Payroll Date. I want the Calculated Pay (...
  • Greg_Deckler's avatar
    Greg_Deckler
    6 years ago

    OK, the failure here was that your sample data was not representative of your actual data. In your actual data, we have to account for Employee_ID. So, that can be done like this:

     

    Result = 
        VAR __CalculatedPay = 'Sheet1'[Calculated Pay (N)]
        VAR __Next = 
            MINX(
                FILTER(
                    'Sheet1',
                    'Sheet1'[Calculation Date] > EARLIER('Sheet1'[Calculation Date]) &&
                        'Sheet1'[Employee_ID] = EARLIER('Sheet1'[Employee_ID])
                ),
                'Sheet1'[Calculation Date]
            )
        VAR __NextPay = 
            MINX(
                FILTER(
                    'Sheet1',
                    'Sheet1'[Calculation Date] = __Next &&
                        'Sheet1'[Employee_ID] = EARLIER('Sheet1'[Employee_ID])
                ),
                'Sheet1'[Calculated Pay (N)]
            )
    RETURN
        IF(__CalculatedPay <> __NextPay,__CalculatedPay,0)

     

    Updated PBIX is attached.