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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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