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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Calculate a bi-weekly date range column

Hi all, 

 

I'm trying to add a date range column that would calculate every 2 weeks (starting on a Monday). e.g. 06/09/2021 - 19/09/2021 etc.

Ideally I would also like it to have a custom start date, as the bi-weekly date ranges are related to target setting (which haven't been done yet), so if targets are set on the 13th of September, the date range column can start 13/09/21 - 26/09/2021, and continue every two weeks from there for the rest of the year. 

 

My date table currently looks like this: 

daviesn_0-1630513821792.png

 

I got as far as adding the 'calendar week date range' column using this formula: https://community.powerbi.com/t5/Desktop/Create-date-range-column-for-weeks-in-DAX/m-p/618265 but can't figure out a workaround to make that bi-weekly instead of weekly. 

 

Any help would be much appreciated!! thank you. 

1 ACCEPTED SOLUTION

@Anonymous Maybe:

Column = 
  VAR __Week = [Week Number]
  VAR __Year = [Year]
  VAR __Min = MINX(FILTER('Table',[Week Number] = __Week && [Year] = __Year),[Date])
  VAR __Max = MAXX(FILTER('Table',[Week Number] = __Week && [Year] = __Year),[Date])
RETURN
  __Min & "-" & __Max

@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Greg_Deckler thanks so much for the reply! Could you explain that a bit more please? at the moment it's giving me a range from my min to max date in the whole date table:

daviesn_0-1630577284077.png

Column =
VAR __Week = [Week Number]
VAR __Min = MINX(FILTER('Date', [Week Number] = __Week),[Date])
VAR __Max = MAXX(FILTER('Date',[Week Number] = __Week),[Date])
RETURN
__Min & "-" & __Max

@Anonymous Maybe:

Column = 
  VAR __Week = [Week Number]
  VAR __Year = [Year]
  VAR __Min = MINX(FILTER('Table',[Week Number] = __Week && [Year] = __Year),[Date])
  VAR __Max = MAXX(FILTER('Table',[Week Number] = __Week && [Year] = __Year),[Date])
RETURN
  __Min & "-" & __Max

@ 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!:
Mastering Power BI 2nd Edition

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

@Anonymous Well, maybe something along the lines of:

Column = 
  VAR __Week = [Week Number]
  VAR __Min = MINX(FILTER('Table',[Week Number] = __Week),[Date])
  VAR __Max = MAXX(FILTER('Table',[Week Number] = __Week),[Date])
RETURN
  __Min & "-" & __Max

@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.