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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

List.Dates between dates

I am looking for a formula that will look at the added date and number of months then add a column for each month. For example Added date is 25/06/2007 and the number of months is 5 the 1st column would be added date +1 2nd columns would be added date +2 up to the number of months. Obviously the number of months will change dummy date below for exmaple.

 

Capture.JPG

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

try this code, you will need to replace the blue part to match your queries

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNA1MNQ1MFbSUTJWitUBC5nrGpjoGpgChcyUYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Added Date" = _t, #"Number Months" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Added Date", type date}, {"Number Months", Int64.Type}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type", "Custom", each Table.ToList(Table.TransformColumnTypes(Table.SelectColumns(Table.AddColumn(Table.ExpandListColumn(#table( type table [Date=date,Days=date], {{[Added Date], {1..[Number Months]}}}), "Days"), "Custom", each Date.AddMonths([Date],[Days])), {"Custom"}),{{"Custom", type text}}))),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom1", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1", "Custom.2", "Custom.3", "Custom.4", "Custom.5", "Custom.6"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Custom.1", type date}, {"Custom.2", type date}, {"Custom.3", type date}, {"Custom.4", type date}, {"Custom.5", type date}, {"Custom.6", type date}})
in
    #"Changed Type1"


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

2 REPLIES 2
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Stachu
Community Champion
Community Champion

try this code, you will need to replace the blue part to match your queries

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNA1MNQ1MFbSUTJWitUBC5nrGpjoGpgChcyUYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Added Date" = _t, #"Number Months" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Added Date", type date}, {"Number Months", Int64.Type}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type", "Custom", each Table.ToList(Table.TransformColumnTypes(Table.SelectColumns(Table.AddColumn(Table.ExpandListColumn(#table( type table [Date=date,Days=date], {{[Added Date], {1..[Number Months]}}}), "Days"), "Custom", each Date.AddMonths([Date],[Days])), {"Custom"}),{{"Custom", type text}}))),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom1", {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1", "Custom.2", "Custom.3", "Custom.4", "Custom.5", "Custom.6"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Custom.1", type date}, {"Custom.2", type date}, {"Custom.3", type date}, {"Custom.4", type date}, {"Custom.5", type date}, {"Custom.6", type date}})
in
    #"Changed Type1"


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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