Forum Discussion
balak
Microsoft Employee
4 years agoHow to generate explode the datediff between 2 dates to multiple rows
I have 2 columns , startdate and processeddate and I want to explore the datediff between these 2 dates to muliptle rows like below in Dax and i am assuming this will be separate table and need to ...
Ashish_Mathur
Super User
4 years agoHi,
This M code works
let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "Duration", each 1*([endDate]-[StartDate])),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Duration", Int64.Type}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type", "Custom", each {1..[Duration]}),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom1", "Custom"),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Duration"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns",{{"StartDate", type date}, {"endDate", type date}})
in
#"Changed Type1"
Hope this helps.
PaginatedDino
Helper I
3 years agoAshish_Mathur Thanks this worked for me with but with an integer range use case. It was a small look up table that eventually results in 20.000 exploded rows, so not a very huge table. Performance is ok.
- Ashish_Mathur3 years ago
Super User
Glad to know. Thank you.