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
Tand81
Regular Visitor

Grouped fill down by Dates

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. 

image.png

Kind regards

Thomas

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Tand81 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

b1.png

 

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:

b2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @Tand81 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

b1.png

 

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:

b2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@amitchandakThank you. 

I tried, but still have not achieved what I was looking for. 

 

It did not work with this one:

 

"CALCULATE(COUNTX(SUMMARIZE(filter(CROSSJOIN('Data';'DimDate');'DimDate'[Date] >= 'Data'[Date] && 'DimDate'[Date]<= 'Data'[Dispatch date]);'Data'[OrdPos];'DimDate'[Date]);'DimDate'[Date]))" 

It works perfect, thank you 🙂

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.