How to add rows for dates between start and end dates in Power BI date range data

1–2 minutes
screenshot1
Screenshot from appsource.microsoft.com’s app detail page.

In Power BI there are several custom visuals available, such as Elastacloud’s Calendar Visual, that show the density of events over time. However, if your data includes date ranges (start date with a different end date, such as task/project lists), visuals like these will only understand one of the two dates (whichever you’ve chosen for the data value) and none of the dates in between will be accounted for, making your data visualization incorrect.

You can, however, “expand” these date ranges or durations to create rows for all the dates including start, end and those in between. This way each date that’s part of the range is then graphed appropriately.

  1. Click “Edit queries” to open Power Query editor
    PBIDesktop_2018-08-08_14-49-57
  2. Make sure your date columns are date (not date/time) format
    2018-08-08_14-53-42
  3. Create a custom column
    PBIDesktop_2018-08-08_14-56-19
  4. Change the name to “Date” and paste the following after the equals (“=”) sign:
    { Number.From([EventDate])..Number.From([EndDate]) }

    2018-08-08_15-14-54

  5. Click OK
  6. Click the “diverging-arrow” icon next to “Date” and click “Expand to new rows”. Notice the addition of new rows.
    2018-08-08_15-23-49
  7. Change the column type to “Date”
    2018-08-08_15-25-21
  8. You may wish to delete your “start date” and “end date” columns but certainly don’t need to.
  9. Click “Close and Apply”
    PBIDesktop_2018-08-08_15-26-27
  10. Use your new “Date” column instead of “start date” or “end date” in your visualization pane values. Notice how more squares are filled in for dates that fell into ranges previously unaccounted for.
    2018-08-08_15-30-31

Discover more from Nate Chamberlain

Subscribe to get the latest posts sent to your email.

15 responses to “How to add rows for dates between start and end dates in Power BI date range data”

  1. Z. Avatar
    Z.

    The Elastacloud’s Calendar Visual is not available anymore. Any similar visual you could recommend?

  2. Luz Avatar

    Hi, I have question, this solution was awesome, but now I need to count the employee IDs who has a certain date as the start date, given that the ids repeat and the start date also repeat with the creation of the new rows it has become difficult.
    The expanded column i am calling “transaction date”, so what I need to do is something like “countdistinct(employee id),filter(all(date),firstdate(transaction date)” and put it in a card that will be filtered by the rest of the viz (month or week ending). I want to know how many people started working on a certain period.
    As of now it looks to be counting every time a date within the month or week ending appears vs. counting only if it is the first date that it appears for a certain employee id.

  3. KellyC Avatar
    KellyC

    Is it possible to add just months, not days, between the dates

    1. chariot Avatar
      chariot

      Hi, did you find the solution in order to have months and not days? thanks in advance

  4. Domenico Pontoriero Avatar
    Domenico Pontoriero

    I am so impressed at how simply you laid out this solution. Have been looking for something like this for eons. Thank you.

  5. tom grayham Avatar
    tom grayham

    is there a way to make it ignore entries that star date and end date are “null” its giving me an error because of that

  6. Joel Valentine Avatar
    Joel Valentine

    Thank 🙂
    Worked a treat!

  7. Jocelyn Beier Avatar
    Jocelyn Beier

    I’m Following the instructions, and do get dates, however, I do not get any new rows. What am I doing wrong?

  8. Leo Avatar
    Leo

    Is it possible to break down also including hour?

  9. Mark Blackburn Avatar
    Mark Blackburn

    So helpful, thank you

  10. Rolf Avatar
    Rolf

    Hi, this is great! But i need it to work with minutes to, is this possible?

    1. littlenemo Avatar

      Did your find any solution? I am having same issue like you are searching for also

  11. Lifan Avatar
    Lifan

    This is unbelievable! I’ve been pulling my hair trying to find this answer. Thank you a million times!

  12. ejo Avatar

    Hi, thanks for article. It was very helpful. However a whole number field I had was not divided into equal parts. Is there a way I can do this?

    1. tt Avatar
      tt

      Ejo: I walked into this now, almost a year later. I’m quite noob with this but my solution is that before you expand, you substract the end date-start date, then add custom column 1 and divide this with the previous number.

      You will get a number 0,00x…. on each row, then you can use this as a multiplier to multiply your budget, etc. numbers.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Nate Chamberlain

Subscribe now to keep reading and get access to the full archive.

Continue reading