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! Learn more

Reply
MyWeeLola
Helper II
Helper II

Measure to filter the last 7 days of values

Good morning

I have a table that provides me with figures as in the schema below

 

Date individual value

1/4/24  Lola    1.2

1/4/24  Lola     0.7

2/4/24  Lola     2.5

Each day may have more than one entry per individual and several individuals

 

I have the following measure which provides me with daily values

Daily Exposure = SQRT(SUMX ( ADDCOLUMNS ( tblHavs, "SQ2", POWER ( tblHavs[PEV], 2 ) ), [SQ2] ))
I am doing a daily sum of squares for the values entered.
 
This measure works as required as I have a slicer that allows me to select individuals and another for date periods.
in addition, I have created this measure 
My Max Date = CALCULATE(MAX(tblHavs[Date]))
 
What I now need to do, and where I am struggling is to sum the squares of the measure, "Daily Exposure" for the "My Max Date" selected by my filter and the previous 6 days to that date.
 
As an example, if I select no date filter, then the calculation to sum the squares would start from figures entered today plus the previous 6 days.
If my filter started from the previous month, then it would be from March 31st back to the 25th.
 
I look forward to any assistance and appreciate any help with this.
Lola
 
 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MyWeeLola , You can try like

 

Last 7 =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = _max -7
return
CALCULATE([Your Measure] ,DATESBETWEEN('Date'[Date],_min,_max))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@MyWeeLola , You can try like

 

Last 7 =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = _max -7
return
CALCULATE([Your Measure] ,DATESBETWEEN('Date'[Date],_min,_max))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak This is perfect, thank you for taking the time to do that.

Lola

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.

Top Solution Authors