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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Anonymous
Not applicable

Calculated table with all dates between two dates

Hi All,

 

I am trying to create a calculated table that lists all tickets and a record for each day that it was opened based on the Start Date and End Date columns. If the End Date is blank (i.e. the ticket is still open), I want it to list all dates from the start date to today's date.

 

For example, today's date is 5/15/2018. I would want the data from this table:

TicketStart DateEnd Date

15/11/20185/14/2018
25/11/2018 

 

To calculate into this:

TicketDate

15/11/2018
15/12/2018
15/13/2018
15/14/2018
25/11/2018
25/12/2018
25/13/2018
25/14/2018
25/15/2018

 

I can't quite get there. Any ideas?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

FYI - I pieced together some google searches and was able to do what I needed in the query editor:

  1. Duplicated my source table
  2. Created a custom column with today's date using the following: DateTime.LocalNow() as datetime
  3. Changed that column to a date type instead of datetime
  4. Added another custom column using: if [Closed Date] = null then { Number.From([Opened Date])..Number.From([Today]) } else { Number.From([Opened Date])..Number.From([Closed Date]) }
  5. Expanded the column to rows
  6. Changed to a Date type
  7. Removed all the remaining columns I didn't need.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

FYI - I pieced together some google searches and was able to do what I needed in the query editor:

  1. Duplicated my source table
  2. Created a custom column with today's date using the following: DateTime.LocalNow() as datetime
  3. Changed that column to a date type instead of datetime
  4. Added another custom column using: if [Closed Date] = null then { Number.From([Opened Date])..Number.From([Today]) } else { Number.From([Opened Date])..Number.From([Closed Date]) }
  5. Expanded the column to rows
  6. Changed to a Date type
  7. Removed all the remaining columns I didn't need.
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @Anonymous

 

I think this calculated table gets close.  I have attached a PBIX file.

 

Table 2 = 
SELECTCOLUMNS(
    GENERATE(
            'Table1',
            FILTER(
                CALENDAR(MIN('Table1'[StartDate]),MAX('Table1'[DateEnd]))
                ,[Date]>=[StartDate] && [Date] <= IF(NOT IsBlank([DateEnd]),[DateEnd],MAX('Table1'[DateEnd])
                )
            )
       ),"ID",[ID],"TicketDate",[Date])

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

@Phil_Seamark is there a way to do this but look at months so rather looking at every day date look at every month date?

Anonymous
Not applicable

if there a way to do this but look at months so rather looking at every day date look at every month date?

Anonymous
Not applicable

Thanks Phil, however it didn't list today's date for the ID 2 record, which is the one that didn't have an end date. I was able to piece together a solution from some googling I did and posted it as a solution for reference.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.