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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
onedayover
Helper III
Helper III

Finding the maximum value within a 12 month date range

Hi All

I need help in creating a new column in my table (MaxValueWithinRange) where the value returned is the maximum value within a 12 month date range from a corresponding date in the row.

For example, if the date (in the "Date" column) is 17/09/2021, the date range I would want to look up the max value from would be 18/09/2020 to 17/09/2021. The max value within this range is 17407.

Please see example below of what I'm trying to achieve. Please note, the "From" and "To" columns are only in this example and not actually in my PBI table.

Many thanks
darls15

 

Example.JPG

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pibx file.

It is for creating a new column.

 

Untitled.png

 

MaxValueWithinRange CC =
VAR _rangeenddate = Data[Date]
VAR _rangestartdate =
    DATE ( YEAR ( _rangeenddate ) - 1, MONTH ( _rangeenddate ), DAY ( _rangeenddate ) ) + 1
VAR _result =
    MAXX (
        FILTER ( Data, Data[Date] >= _rangestartdate && Data[Date] <= _rangeenddate ),
        Data[TotalUsers]
    )
RETURN
    _result

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
onedayover
Helper III
Helper III

Yes that's exactly it! It works perfectly with my data, thank you so much Jihwan_Kim 😊

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pibx file.

It is for creating a new column.

 

Untitled.png

 

MaxValueWithinRange CC =
VAR _rangeenddate = Data[Date]
VAR _rangestartdate =
    DATE ( YEAR ( _rangeenddate ) - 1, MONTH ( _rangeenddate ), DAY ( _rangeenddate ) ) + 1
VAR _result =
    MAXX (
        FILTER ( Data, Data[Date] >= _rangestartdate && Data[Date] <= _rangeenddate ),
        Data[TotalUsers]
    )
RETURN
    _result

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.