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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
mgcchkn
Frequent Visitor

Percent deviation from previous value

IndexNameTest DateTest StatusTest DurationCurrent TestPrevious Test
331891John8/10/2022APPROVED24200 
331892John5/4/2022APPROVED2471 
331893John7/6/2022APPROVED241066 
331894John6/17/2022APPROVED24228 
331895John9/17/2020APPROVED24113 

 

Above is my sample data.

 

I'm trying to figure out percentage of deviation from previous test.  I can't even figure out how to get the previous test to show up in the Previous Test column.  Ultimately, there would be a 8th column that had the percentage of deviation.

 

As you can see, the index column is missing some numbers because of filtering.  So these tests are for a particular "student" which is filtered via a drill through with a measure called "selected_student."  (selected_student = var selected_student = SELECTEDVALUE(student[name]) return "Test History for Student: " & UNICHAR(10) & selected_student)

 

Thanks in advance! I've been working on this and googling it for 2 days and can't figure it out.

1 ACCEPTED SOLUTION

Hi, @mgcchkn 

Take a try formula like below:

Previous Test = 
VAR _PreviousTestDate =
    CALCULATE (
        MAX ( Student[Test Date] ),
        FILTER (
            ALL ( Student ),
            Student[Name] = MAX ( Student[Name] )
                && Student[Test Date] < MAX ( Student[Test Date] )
        )
    )
RETURN
    CALCULATE (
        MAX ( Student[Current Test] ),
        FILTER (
            ALL ( Student ),
            Student[Name] = MAX ( Student[Name] )
                && Student[Test Date] = _PreviousTestDate
        )
    )
Percenatge = DIVIDE(MAX(Student[Current Test])-[Previous Test],[Previous Test])

Best Regards,
Community Support Team _ Eason

View solution in original post

3 REPLIES 3
mgcchkn
Frequent Visitor

I figured it out, but it takes forever for it to load now.  It takes between 60-90 seconds.

Hi, @mgcchkn 

Take a try formula like below:

Previous Test = 
VAR _PreviousTestDate =
    CALCULATE (
        MAX ( Student[Test Date] ),
        FILTER (
            ALL ( Student ),
            Student[Name] = MAX ( Student[Name] )
                && Student[Test Date] < MAX ( Student[Test Date] )
        )
    )
RETURN
    CALCULATE (
        MAX ( Student[Current Test] ),
        FILTER (
            ALL ( Student ),
            Student[Name] = MAX ( Student[Name] )
                && Student[Test Date] = _PreviousTestDate
        )
    )
Percenatge = DIVIDE(MAX(Student[Current Test])-[Previous Test],[Previous Test])

Best Regards,
Community Support Team _ Eason

That worked great!  Thank you!!!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors