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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
dt_mc
Frequent Visitor

Creating Date Schedules using M

Hi

suppose i have a table with 3 fields - ID, StartDate, EndDate

suppose 1 | 1/4/2017 | 4/15/2017

 

Is there a way to use that to create monthly row data for each month in the time frame?  would be great if start/end align so something like this:

 

ID | Date 

1 | 1/4/2017

1 | 2/28/2017

1 | 3/31/2017

1 | 4/15/2017

 

 

1 ACCEPTED SOLUTION

@dt_mc,

 

Review the function by @ImkeF at https://www.thebiccountant.com/2017/12/11/date-datesbetween-retrieve-dates-between-2-dates-power-bi-.... Possibly this is the solution you need.

 

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

4 REPLIES 4
Anonymous
Not applicable

I would try using the Unpivot function.  You'll find it in the transform tab of the ribbon menu.

but would unpivot be able to create the rows for the months between start and end dates? wouldn't that only create two rows (start end)

@dt_mc,

 

Review the function by @ImkeF at https://www.thebiccountant.com/2017/12/11/date-datesbetween-retrieve-dates-between-2-dates-power-bi-.... Possibly this is the solution you need.

 

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



@dt_mc,

 

Please try this formula ( change to adapt with your source):

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"StartDate", type date}, {"EndDate", type date}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [EndDate]-[StartDate],Int64.Type),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type1", "Custom.1", each Number.IntegerDivide([Custom],30)+1),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom.2", each List.Repeat(#"Changed Type1"[StartDate],[Custom.1])),
    #"Expanded Custom.2" = Table.ExpandListColumn(#"Added Custom2", "Custom.2"),
    #"Added Index" = Table.AddIndexColumn(#"Expanded Custom.2", "Index", 1, 1),
    #"Added Custom3" = Table.AddColumn(#"Added Index", "Custom.3", each if [Index]=1 then [StartDate] else if [Index]=[Custom.1] then [EndDate] else Date.EndOfMonth(Date.AddMonths([StartDate],[Index]-1))),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom3",{"ID", "Custom.3"})
in
    #"Removed Other Columns"

Hope it helps...

 

Ninter

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.