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
coast2coast
New Member

DATESINPERIOD based on dynamic date range AND second dynamic criteria

Hello - this is my first post here and I am new to PowerBI, so please bear with me 🙂 Thank you!

 

I am trying to dynamically sum a value based on a changing date range (3 weeks +/- current row date)

I also need it to have a criteria to only sum rows for that date range for a specific person (ID)

 

I saw that DATESINPERIOD could get me close to what I need but not sure how to incorporate the 2nd criteria as well so it doesn't sum the values in column A for specific dates for everyone instead of just the ID for the row we are on. 

 

Example: Looking for new column value = Sum of Days +/- 3 weeks based on corp id and week = row

 

coast2coast_0-1699992430538.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @coast2coast ,

Below is my table:

vxiandatmsft_0-1700115022867.png

The following DAX might work for you:

 

Measure = 
 var result = 
  CALCULATE(
    SUMX('Table' , 'Table'[Days]),
    DATESINPERIOD('Table'[Week], MIN('Table'[Week]) , 21, DAY )
)
return result

 

The final output is shown in the following figure:

vxiandatmsft_1-1700115051866.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
coast2coast
New Member

@Anonymous thank you for the response. In your solution, where is the ID criteria determined? I need to be able to slice on both ID and Week where the table could have up to 90K distinct IDs with values for every week. 

Also - I keep getting "not enough memory" errors when i try to do even a simple measure like this one, any tips for that? I can't limit my data any more than it is already. 

Anonymous
Not applicable

Hi @coast2coast ,

Below is my table:

vxiandatmsft_0-1700115022867.png

The following DAX might work for you:

 

Measure = 
 var result = 
  CALCULATE(
    SUMX('Table' , 'Table'[Days]),
    DATESINPERIOD('Table'[Week], MIN('Table'[Week]) , 21, DAY )
)
return result

 

The final output is shown in the following figure:

vxiandatmsft_1-1700115051866.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.