Forum Discussion
balak
4 years agoMicrosoft Employee
How 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
4 years agoSuper User
Hi,
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
3 years agoHelper I
Ashish_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 agoSuper User
Glad to know. Thank you.