Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
4 years ago
Solved

Calculate an exact day between two given dates

Good morning, I would like to make a calculated measurement or column, by which I can calculate an exact calendar day. I have a start date, an end facha, and a number to divide by. The idea is to t...
  • v-jingzhang's avatar
    4 years ago

    Hi Anonymous 

     

    I recommend to use Power Query to get the exact dates between two given dates. You can open Power Query Editor from Home > Transform data in Power BI Desktop. Then follow below steps:

     

    1. Add a custom column to calculate the length of each period. 

    Duration.Days( ([End Date] - [Start Date]) / [Period] )

     

    2. Add the second custom column. In every cell of the column, you will have a list that has all exact dates between the given dates. 

    List.Dates( Date.AddDays( [Start Date], [Period Days]), [Period] - 1, #duration([Period Days],0,0,0) )

     

    3. For the list column, you can choose to expand it to new rows or extract values per your need. 

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.