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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.