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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
OhLookAnError
Helper I
Helper I

How to exclude the last seven days in Dax

is there a way to add to this measure to exclude anything in the last seve days?

 

I tried to filter my data in power query to exclude the last seven days but there doesn't seem to be a way...

 

 Revenue per Hour =
    Var Hours = Calculate(SUM(tblEnvPerManHr_Summary[TotalHrs]),
                DATESINPERIOD(tblEnvPerManHr_Summary[ReportDate],
                LASTDATE(tblEnvPerManHr_Summary[ReportDate]),-30,DAY))
    VAR Revenue = Calculate(SUM(tblEnvPerManHr_Summary[Revenue]),
                DATESINPERIOD(tblEnvPerManHr_Summary[ReportDate],
                LASTDATE(tblEnvPerManHr_Summary[ReportDate]),-30,DAY))
RETURN
Divide(Revenue,Hours,0)
5 REPLIES 5
andhiii079845
Solution Sage
Solution Sage

 Var Hours = Calculate(SUM(tblEnvPerManHr_Summary[TotalHrs]),
                DATESINPERIOD(tblEnvPerManHr_Summary[ReportDate],
                LASTDATE(tblEnvPerManHr_Summary[ReportDate]),-30,DAY))
->
 Var Hours = Calculate(SUM(tblEnvPerManHr_Summary[TotalHrs]),
                DATESINPERIOD(dateadd(tblEnvPerManHr_Summary[ReportDate],-7,day),
                LASTDATE(tblEnvPerManHr_Summary[ReportDate]),-30,DAY))
 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




This is what I'm seeing for that:

OhLookAnError_0-1677602299790.png

 

Thank you. Perhaps try to add a VAR for your date

VAR 7day = dateadd(tblEnvPerManHr_Summary[ReportDate],-7,day)

 

And use it in your measure later? 

 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




andhiii079845
Solution Sage
Solution Sage

Perhaps try dateadd(tblEnvPerManHr_Summary[ReportDate],-7,day) ?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I've tried to add that to the measure in a couple different spots but cant get it to work. Where would I add that in? 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.