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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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))

 

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))

 

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Top Kudoed Authors