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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
buchta
Frequent Visitor

ETL trick in power query

Hi 

 

I have a question with a litle challange 

 

i have data like this.. 

Order      Name   Type        ship      From                     To                        Days

001ABCcdcbcb20/2/202225/2/20226

 

and would like to end up with something like this

Order       Name      Type        ship      Date

001ABCcdcbcb20/2/2022
001ABCcdcbcb21/2/2022
001ABCcdcbcb22/2/2022
001ABCcdcbcb23/2/2022
001ABCcdcbcb24/2/2022
001ABCcdcbcb25/2/2022




what is the best way to achieve this in power query where i am using Direc Query as the connection mode
the DQ is the challange as I would prefer the query not to break. 🙂

 

my thoughts so far went to create table with dates only and then add some dynamic logic that would add new column everytime there is new ship .. and then unpivot al this and remove records where there is 0 value .. but that doesnt sounds right. and was breaking 

 

thank you for your help.. 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@buchta , I doubt that you can do this in Direct Query mode, we can generate a list and add that dates and expand. But I doubt that will work in Direct Query

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJ0cgaSySnJQDIpOQlIGhnoG+kbGRgZgdimMHasTrQSSMTF1Q1IFhcXA8mc/ByQGiMk9RZw9bEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Order = _t, Name = _t, Type = _t, ship = _t, From = _t, To = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Order", Int64.Type}, {"Name", type text}, {"Type", type text}, {"ship", type text}, {"From", type date}, {"To", type date}}, "fr"),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Span", each List.Transform({Number.From([From])..Number.From([To])}, Date.From)),
    #"Expanded Span" = Table.ExpandListColumn(#"Added Custom", "Span")
in
    #"Expanded Span"

CNENFRNL_0-1645631326287.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJ0cgaSySnJQDIpOQlIGhnoG+kbGRgZgdimMHasTrQSSMTF1Q1IFhcXA8mc/ByQGiMk9RZw9bEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Order = _t, Name = _t, Type = _t, ship = _t, From = _t, To = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Order", Int64.Type}, {"Name", type text}, {"Type", type text}, {"ship", type text}, {"From", type date}, {"To", type date}}, "fr"),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Span", each List.Transform({Number.From([From])..Number.From([To])}, Date.From)),
    #"Expanded Span" = Table.ExpandListColumn(#"Added Custom", "Span")
in
    #"Expanded Span"

CNENFRNL_0-1645631326287.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

amitchandak
Super User
Super User

@buchta , I doubt that you can do this in Direct Query mode, we can generate a list and add that dates and expand. But I doubt that will work in Direct Query

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.