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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

dax formula date range including today

I need help defining a column to show Today's date minus 7 days and include all dates within that range.  I've created the following columns, hoping I would find a way to get the correct syntax in one column but haven't been able to.   NOTE:  I've looked through all of the posts for ideas but nothing has worked so far.  

 

  • Today = TODAY()
  • Date = CALENDAR("2019-Jan-1", TODAY())
  • OneWeekAgo = 'Date'[Dates]-7  <-- this only gives me the date as of 7 days prior (not a range)
 

 

 

1 ACCEPTED SOLUTION

You will need a calender table hooked to your fact table but then you can use a calculated column like this in your fact table.

Dates List = 
VAR RowDate = table[table date]
RETURN CALCULATE(CONCATENATEX(DATES,DATES[Date],"| "),DATES[Date]<=RowDate,DATES[Date]>=RowDate-7)

View solution in original post

4 REPLIES 4
jdbuchanan71
Super User
Super User

Somthing like this?

Last 7 dates = 
CALCULATE(CONCATENATEX(DATES,DATES[Date]," | "),DATES[Date]<= TODAY() && DATES[Date] >= TODAY()-7)

last7days.jpg

Anonymous
Not applicable

Thanks for the help but the formula doesn't seem to work for me (and I've tried a few variations). 

 

Also, I need my data in a column form rather than a row so CONCATENATEX may not work (since it outputs a row of dates).

 

Actual table and column name is:

  • Table name is 'deals'
  • Column name is 'lost_time'

You will need a calender table hooked to your fact table but then you can use a calculated column like this in your fact table.

Dates List = 
VAR RowDate = table[table date]
RETURN CALCULATE(CONCATENATEX(DATES,DATES[Date],"| "),DATES[Date]<=RowDate,DATES[Date]>=RowDate-7)
Anonymous
Not applicable

Actually I do have a calendar table called 'Date' and it has a column called Dates which is linked to a fact table called 'Deals' and it's column 'lost_time'.

Thanks again for the help.  I'll try to apply the formula you provided.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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