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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ehmacc
Frequent Visitor

Calculating the Difference in Earnings by Employee/Type

Hello!

I am trying to add a caluclated column to my data that will show for lines of current checks the difference in the earnings amount compared to the previous check. I Only need the data to show values if the line is the Current Check Line. Example below- desired output in Red- For employee 1, their Regular Earnings did not change, but their Commission was $300 less; Employee 2 had a $500 increase in Regular Earnings. 

 

Capture.JPG

 Is this possible? The longer term output is that I will be creating a quick table visual for managers to be able to see the difference in the earnings by employee for the current check compared to last check. 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @ehmacc 

Create a calculated column below

Capture14.JPG

diff =
VAR last_date =
    CALCULATE (
        MAX ( 'Table'[Check Date] ),
        FILTER (
            'Table',
            'Table'[Employee ID] = EARLIER ( 'Table'[Employee ID] )
                && 'Table'[Earning Type] = EARLIER ( 'Table'[Earning Type] )
                && 'Table'[Check Date] < EARLIER ( 'Table'[Check Date] )
        )
    )
VAR previous_value =
    CALCULATE (
        SUM ( 'Table'[Current Amount] ),
        FILTER (
            'Table',
            'Table'[Employee ID] = EARLIER ( 'Table'[Employee ID] )
                && 'Table'[Earning Type] = EARLIER ( 'Table'[Earning Type] )
                && 'Table'[Check Date] = last_date
        )
    )
RETURN
    IF ( previous_value = BLANK (), 0, [Current Amount] - previous_value )
Best Regards
Maggie
Community Support Team _ Maggie 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

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @ehmacc 

Create a calculated column below

Capture14.JPG

diff =
VAR last_date =
    CALCULATE (
        MAX ( 'Table'[Check Date] ),
        FILTER (
            'Table',
            'Table'[Employee ID] = EARLIER ( 'Table'[Employee ID] )
                && 'Table'[Earning Type] = EARLIER ( 'Table'[Earning Type] )
                && 'Table'[Check Date] < EARLIER ( 'Table'[Check Date] )
        )
    )
VAR previous_value =
    CALCULATE (
        SUM ( 'Table'[Current Amount] ),
        FILTER (
            'Table',
            'Table'[Employee ID] = EARLIER ( 'Table'[Employee ID] )
                && 'Table'[Earning Type] = EARLIER ( 'Table'[Earning Type] )
                && 'Table'[Check Date] = last_date
        )
    )
RETURN
    IF ( previous_value = BLANK (), 0, [Current Amount] - previous_value )
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.