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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
joshua1990
Post Prodigy
Post Prodigy

Fill rows with no records for each order

Hi experts!

I have a huge transaction table that contains for each order multple rows. This table get's new entries if the state of a order was changed:

Order NumberStateDate Changed
111101.01.2020
111310.01.2020
111515.01.2020

 

As you can see I have now entries/ records for 02.01.2020 for instance.

Since I want to count in a visual at the end the number of orders with state < 5 I will get no results for 14.01.2020 as there is no entry.

 

How can I supplement this table with records for each order between the max and end date?

Or how would you do that?

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Whatever I understand from your post, you need this - See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0VNJRAmN9Q30jAyMDpVgdmLAxRNgAXdwUIm6KLG4ENcZI3xhd2BQsbIQibgxXbgSzNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Order Number" = _t, State = _t, #"Date Changed" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Order Number", Int64.Type}, {"State", Int64.Type}, {"Date Changed", type date}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each try if #"Added Index"[Order Number]{[Index]+1}=[Order Number] then List.Dates([Date Changed],Duration.Days(#"Added Index"[Date Changed]{[Index]+1}-[Date Changed])+1,#duration(1,0,0,0)) else {[Date Changed]} otherwise {[Date Changed]}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Date Changed", "Index"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns",{{"Custom", type date}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Custom", "Date Changed"}})
in
    #"Renamed Columns"

 

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

Whatever I understand from your post, you need this - See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0VNJRAmN9Q30jAyMDpVgdmLAxRNgAXdwUIm6KLG4ENcZI3xhd2BQsbIQibgxXbgSzNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Order Number" = _t, State = _t, #"Date Changed" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Order Number", Int64.Type}, {"State", Int64.Type}, {"Date Changed", type date}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each try if #"Added Index"[Order Number]{[Index]+1}=[Order Number] then List.Dates([Date Changed],Duration.Days(#"Added Index"[Date Changed]{[Index]+1}-[Date Changed])+1,#duration(1,0,0,0)) else {[Date Changed]} otherwise {[Date Changed]}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Date Changed", "Index"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns",{{"Custom", type date}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Custom", "Date Changed"}})
in
    #"Renamed Columns"

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.