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
sergioquerido
Frequent Visitor

Calculate the max value reached in previous weeks (current week not included)

Hello,

I would like to calculate the difference between the MAX value reached in current week and the MAX value reached in previous weeks (current week not included). I am using a WEEKRANK measure to identify weeks and i created the following code. However I do not know how to exclude the current week from the "allweeks" variable.

 

%CHANGE_MS = 
VAR thisweek = CALCULATE(MAX(GPS[Max. Speed]),FILTER(ALLEXCEPT(GPS,GPS[Player Nickname]), GPS[WEEKRANK]=MAX(GPS[WEEKRANK])))
VAR maxweek = MAX(GPS[WEEKRANK])

VAR allweeks = CALCULATE(MAX(GPS[Max. Speed]), ALLEXCEPT(GPS, GPS[Player Nickname]))
RETURN

DIVIDE(thisweek-allweeks,allweeks)

Thanks in advance!

 

SQ

1 REPLY 1
lbendlin
Super User
Super User

if your WEEKRANK starts from 1 then exclude 1 from the list?

 

Please provide sanitized sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

 

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.