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
Anonymous
Not applicable

Group Calendar Date by Last 7 Week Days Dynamically Calculate column

Hi

Need to group dates into last 7 days of my calendar table in a column, I tryied with out luck and finally llooks I´m very close with this calculated column:

First Day 7 Last Days =
VAR today = today()
return
CALCULATE(
max('Calendar Creation'[WeekStart]);DATESINPERIOD('Calendar Creation'[Date];today; -7;DAY))
Of course it's not the desired result, the desired result will be like :
 
 

This dataset it´s refreshed 4 times a day, it´s need to be  grouped  it dynamically in every refresh on this pattern , sorry but i´m lost on this.

Thanks in advance

1 ACCEPTED SOLUTION

Check out Week Starting. https://community.powerbi.com/t5/Quick-Measures-Gallery/Week-Starting/m-p/391487#M123


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

@Anonymous how to  itterate the last 7 days loggic till last 365 days ?? 

 

Greg_Deckler
Community Champion
Community Champion

So, I would think:

Last 7 Days =
VAR __today = TODAY()
RETURN
IF([Date] >= (__today - 7),"Y","N")


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi, thanks but does not work either.

This solution evaluates today and puts and Y if it´s in the last 7 days.

I need to put there max of week start in 7 days rolling periods.

from today to today -6 --> todays date

from day 6 to 14 --> day 6 date

from day 15 to 21 --> day 15 date

etc...

Thanks in advance

You might also want to review Sequential: https://community.powerbi.com/t5/Quick-Measures-Gallery/Sequential/m-p/380231#M116

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks for both resources, I had a quick view and they are very interesting, but does not match to my requirementes, finally I found a solution,:

Max Week Date Last 7 Days =
VAR __date = 'Calendar Cancelled'[Date]
RETURN
CALCULATE(MAX('Calendar Cancelled'[Date]); DATESINPERIOD('Calendar Cancelled'[Date];__date;+7;day))
This groups by the top date of the current date + 7 days 🙂
Thanks all for your help and sorry for the explanation, it is easy but I was lost.
Aprreciatte your help

Check out Week Starting. https://community.powerbi.com/t5/Quick-Measures-Gallery/Week-Starting/m-p/391487#M123


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@Anonymous 

Not sure I got it, but you can get something like that

Rolling 7 = CALCULATE(Max(Sales[Sales Date]),DATESINPERIOD('Date'[Date Filer],MAX(Sales[Sales Date]),-7,Day))

 

Where sales is my transaction table

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
Anonymous
Not applicable

Sorry, nice idea but I tryied and does not work, I need a separate column in calendar table to use it in a chart to group data by this column.

I need it to create it whit out relation to a transaction table. 

This week start day needs to change every 7 days. Example for this week it´s 13-4-2020 for the last 7 days, after 7 days should be  the first day of the second group of 7 days,  etc...

This has to change everyday, your solution places the max value of transaction in all column 😞

Thanks anyway for your time

 

Anonymous
Not applicable

It didn´t allow me to paste the screenshot.... here´s the table desired 😉

DateWeekStartFirst Day 7 Last DaysDesired Result
13/04/2020 0:0013/04/2020 0:0013/04/2020 0:0013/04/2020 0:00
12/04/2020 0:0006/04/2020 0:0013/04/2020 0:0013/04/2020 0:00
11/04/2020 0:0006/04/2020 0:0013/04/2020 0:0013/04/2020 0:00
10/04/2020 0:0006/04/2020 0:0013/04/2020 0:0013/04/2020 0:00
09/04/2020 0:0006/04/2020 0:0013/04/2020 0:0013/04/2020 0:00
08/04/2020 0:0006/04/2020 0:0013/04/2020 0:0013/04/2020 0:00
07/04/2020 0:0006/04/2020 0:0013/04/2020 0:0013/04/2020 0:00
06/04/2020 0:0006/04/2020 0:0013/04/2020 0:0006/04/2020 0:00
05/04/2020 0:0030/03/2020 0:0013/04/2020 0:0006/04/2020 0:00
04/04/2020 0:0030/03/2020 0:0013/04/2020 0:0006/04/2020 0:00
03/04/2020 0:0030/03/2020 0:0013/04/2020 0:0006/04/2020 0:00
02/04/2020 0:0030/03/2020 0:0013/04/2020 0:0006/04/2020 0:00
01/04/2020 0:0030/03/2020 0:0013/04/2020 0:0006/04/2020 0:00
31/03/2020 0:0030/03/2020 0:0013/04/2020 0:0006/04/2020 0:00
30/03/2020 0:0030/03/2020 0:0013/04/2020 0:0030/03/2020 0:00
29/03/2020 0:0023/03/2020 0:0013/04/2020 0:0030/03/2020 0:00
28/03/2020 0:0023/03/2020 0:0013/04/2020 0:0030/03/2020 0:00
27/03/2020 0:0023/03/2020 0:0013/04/2020 0:0030/03/2020 0:00
26/03/2020 0:0023/03/2020 0:0013/04/2020 0:0030/03/2020 0:00
25/03/2020 0:0023/03/2020 0:0013/04/2020 0:0030/03/2020 0:00
24/03/2020 0:0023/03/2020 0:0013/04/2020 0:0030/03/2020 0:00

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.