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.
Hello.
I have an issue in Power query.
First colomn contains order information and second colomns contains Dates(first apperance is Date on stock and second is delivery to customer). How can I fill down dates between these two dates? I have tried to merge with a calender table and filled down, but it does not group the fill down by orders, just till next date.
Kind regards
Thomas
Solved! Go to Solution.
Hi, @Tand81
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may go to 'Query Editor' and input the following codes in 'Advanced Editor'.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc7BCQAhDETRXnJW1ESdWIvYfxvu6i6I6C3M40NqJQFQ1MKTIXXi2PN7BmpmR/xoP9WYNVhNz5Qdx61dFNcWQxnndqr4S6zjrVDO8VROa9w6", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ORdPos = _t, Date = _t, Cont = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ORdPos", type text}, {"Date", type date}, {"Cont", Int64.Type}}),
Custom2 = Table.AddColumn(#"Changed Type","RE",each
let x=[ORdPos],y=[Date]
in
Duration.Days( Table.Max(Table.SelectRows(#"Changed Type",each [ORdPos]=x),"Date")[Date]-y)
),
Custom3 = Table.AddColumn(Custom2,"list",each let x=[RE] in List.Generate(()=>1,each _<=x,each _+1)),
#"Expanded list" = Table.ExpandListColumn(Custom3, "list"),
Custom4 = Table.AddColumn(#"Expanded list","NewDate",each if
[list]<>null then [Date]+#duration([list]-1,0,0,0) else [Date]),
#"Removed Columns" = Table.RemoveColumns(Custom4,{"Date", "RE", "list"})
in
#"Removed Columns"
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Tand81
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may go to 'Query Editor' and input the following codes in 'Advanced Editor'.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc7BCQAhDETRXnJW1ESdWIvYfxvu6i6I6C3M40NqJQFQ1MKTIXXi2PN7BmpmR/xoP9WYNVhNz5Qdx61dFNcWQxnndqr4S6zjrVDO8VROa9w6", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ORdPos = _t, Date = _t, Cont = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ORdPos", type text}, {"Date", type date}, {"Cont", Int64.Type}}),
Custom2 = Table.AddColumn(#"Changed Type","RE",each
let x=[ORdPos],y=[Date]
in
Duration.Days( Table.Max(Table.SelectRows(#"Changed Type",each [ORdPos]=x),"Date")[Date]-y)
),
Custom3 = Table.AddColumn(Custom2,"list",each let x=[RE] in List.Generate(()=>1,each _<=x,each _+1)),
#"Expanded list" = Table.ExpandListColumn(Custom3, "list"),
Custom4 = Table.AddColumn(#"Expanded list","NewDate",each if
[list]<>null then [Date]+#duration([list]-1,0,0,0) else [Date]),
#"Removed Columns" = Table.RemoveColumns(Custom4,{"Date", "RE", "list"})
in
#"Removed Columns"
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Tand81 , refer to this file.
logic need few changes
https://www.dropbox.com/s/bqbei7b8qbq5xez/leavebetweendates.pbix?dl=0
@amitchandakThank you.
I tried, but still have not achieved what I was looking for.
It did not work with this one:
It works perfect, thank you 🙂
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
117 | |
104 | |
77 | |
73 | |
52 |
User | Count |
---|---|
145 | |
109 | |
109 | |
90 | |
64 |