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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
samdep
Advocate II
Advocate II

Difference Between Two Related Rows in a Table

Hi Community,

 

I have a table, similar to the below, where I'd like to show the difference between the manager's rating of the direct report and the direct report's rating of themselves. I'd like to create a measure that looks at the difference between the manager's rating and the direct report's rating, and from there, add a flag within the cell if the difference between the two ratings is greater than or equal to 2.

 

Previously, I had used the following DAX measure and it worked fine, but now it's throwing an error with 'EARLIER'. 

 

Judgment Variance = 
VAR _MAX = MAXX(FILTER('Assessments', 'Assessment'[Index] < EARLIER([Index]) && 'Assessment{'Manager & Direct Report'] = EARLIER('Assessment{'Manager & Direct Report'])), [Index]

 

VAR _RATING = 'Assessment'[Judgment] - MAXX(FILTER('Assessments', 'Assessment'[Index] < EARLIER([Index]) && 'Assessment{'Manager & Direct Report'] = EARLIER('Assessment{'Manager & Direct Report'])), 'Assessment'[Judgment]

 

RETURN

IF(_RATING = 'Assessment'[Judgment], BLANK(),
IF(_RATING = 0, BLANK(), ABS(_RATING))
)

 

Appreciate any guidance!

 

DateIndexNameTypeManagerMgr &  ReportJudgment RatingJudgment Variance
3/31/2023 4:00pm1JohnAssessment of Report John-Sally51
4/2/2023 5:00pm2SallySelf-AssessmentJohnJohn-Sally4

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @samdep ,

First, please make sure that what you are creating is a calculated column not a measure, then update its formula as below to get the expected result:

Judgment Variance = 
VAR _nextindex =
    MINX (
        FILTER (
            'Assessment',
            'Assessment'[Index] > EARLIER ( [Index] )
                && 'Assessment'[Manager & Direct Report] = 'Assessment'[Manager & Direct Report]
        ),
        [Index]
    )
VAR _nextrating =
    MAXX (
        FILTER (
            'Assessment',
            'Assessment'[Index] = _nextindex
                && 'Assessment'[Manager & Direct Report] = EARLIER ( 'Assessment'[Manager & Direct Report] )
        ),
        [Judgment]
    )
RETURN
    IF (
        ISBLANK ( _nextrating )
            || _nextrating = 'Assessment'[Judgment],
        BLANK (),
        ABS ( 'Assessment'[Judgment] - _nextrating )
    )

vyiruanmsft_1-1682404898261.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @samdep ,

First, please make sure that what you are creating is a calculated column not a measure, then update its formula as below to get the expected result:

Judgment Variance = 
VAR _nextindex =
    MINX (
        FILTER (
            'Assessment',
            'Assessment'[Index] > EARLIER ( [Index] )
                && 'Assessment'[Manager & Direct Report] = 'Assessment'[Manager & Direct Report]
        ),
        [Index]
    )
VAR _nextrating =
    MAXX (
        FILTER (
            'Assessment',
            'Assessment'[Index] = _nextindex
                && 'Assessment'[Manager & Direct Report] = EARLIER ( 'Assessment'[Manager & Direct Report] )
        ),
        [Judgment]
    )
RETURN
    IF (
        ISBLANK ( _nextrating )
            || _nextrating = 'Assessment'[Judgment],
        BLANK (),
        ABS ( 'Assessment'[Judgment] - _nextrating )
    )

vyiruanmsft_1-1682404898261.png

Best Regards

amitchandak
Super User
Super User

@samdep , try like

 

Judgment Variance =
VAR _MAX = MAXX(FILTER('Assessments', 'Assessment'[Index] < EARLIER([Index]) && 'Assessment'[Manager & Direct Report] = EARLIER('Assessment'[Manager & Direct Report])), 'Assessment'[Index])

 

VAR _RATING = 'Assessment'[Judgment] - MAXX(FILTER('Assessments', 'Assessment'[Index] =_max && 'Assessment'[Manager & Direct Report] = EARLIER('Assessment'[Manager & Direct Report])), 'Assessment'[Judgment])

 

RETURN

IF(_RATING = 'Assessment'[Judgment], BLANK(),
IF(_RATING = 0, BLANK(), ABS(_RATING))
)

 

 

Power BI DAX- Earlier, I should have known Earlier: https://www.youtube.com/watch?v=cN8AO3_vmlY&t=17820s

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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