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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Novice_YVR
Regular Visitor

Running minimum within date ranges

Hi everyone,

 

I am trying to figure out how to calculate a running minimum value within certain timeframes. 

Let's say I am working with the data below. 

For each "Account", I need to calculate the minimum within the last 5 days as an example (I assume the formula would be adjusted for different ranges like 30 days, 1 year, etc.).

For 8/16 to 8/19, the value should be 0 as 5 days hasn't passed yet and my expected values are in the last column. 

 

DateAccountValueMinimum within last 5 days
8/16/2023A100 
8/17/2023A200 
8/18/2023A300 
8/19/2023A400 
8/20/2023A500100
8/21/2023A600200
8/22/2023A700300
8/23/2023A800400
8/24/2023A900500
8/25/2023A1000600
8/26/2023A1100700
8/27/2023A1200800
8/28/2023A1300900
8/29/2023A14001000
8/30/2023A15001100
8/31/2023A16001200
9/1/2023A17001300
9/2/2023A18001400
9/3/2023A19001500
9/4/2023A20001600
9/5/2023A21001700
9/6/2023A22001800
9/7/2023A23001900
9/8/2023A24002000
9/9/2023A25002100
9/10/2023A26002200
9/11/2023A27002300
9/12/2023A28002400
9/13/2023A29002500
9/14/2023A30002600
9/15/2023A31002700
9/16/2023A32002800
9/17/2023A33002900
9/18/2023A34003000
9/19/2023A35003100
9/20/2023A36003200
8/16/2023B100 
8/17/2023B200 
8/18/2023B300 
8/19/2023B400 
8/20/2023B500100
8/21/2023B600200
8/22/2023B700300
8/23/2023B800400
8/24/2023B900500
8/25/2023B11
8/26/2023B11001
8/27/2023B12001
8/28/2023B13001
8/29/2023B14001
8/30/2023B15001100
8/31/2023B16001200
9/1/2023B17001300
9/2/2023B18001400
9/3/2023B19001500
9/4/2023B20001600
9/5/2023B21001700
9/6/2023B22001800
9/7/2023B23001900
9/8/2023B24002000
9/9/2023B22
9/10/2023B26002
9/11/2023B27002
9/12/2023B28002
9/13/2023B29002
9/14/2023B30002600
9/15/2023B31002700
9/16/2023B32002800
9/17/2023B33002900
9/18/2023B34003000
9/19/2023B35003100
9/20/2023B36003200

 

I have searched and tried to adapt from the following measures in these links but always end up with a ciruclar dependency error. 

Solved: Re: Filter minimum value per category within date ... - Microsoft Fabric Community

 

Solved: lookup value within date range - Microsoft Fabric Community

 

Solved: Re: Calculate Min Values within a Specific and Dyn... - Microsoft Fabric Community

 

Thank you and much appreciation. 

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column, not a measure.

 

Jihwan_Kim_0-1692204433375.png

 

 

Minimum within last 5 days CC =
VAR _t =
    WINDOW (
        -4,
        REL,
        0,
        REL,
        SUMMARIZE ( Data, Data[Date], Data[Account], Data[Value] ),
        ORDERBY ( Data[Date], ASC ),
        ,
        PARTITIONBY ( Data[Account] )
    )
VAR _condition =
    COUNTROWS ( _t ) = 5
RETURN
    IF ( _condition, MINX ( _t, Data[Value] ), 0 )

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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