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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors