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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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