Forum Discussion
Show continuous date and reflect '0' for missing data
- 5 years ago
Hi, Anonymous
Based on your description, I created data to reproduce your scenario, The pbix file is attached in the end.
Table:
You may create a new query and paste the following codes in 'Advanced Editor'.
let Source = let mindate=List.Min(Table[Delivered Date]),maxdate=List.Max(Table[Delivered Date]) in List.Dates( mindate, Duration.Days( maxdate-mindate)+1, #duration(1,0,0,0) ), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Delivered Date"}}), #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Cust", each Table.Distinct( Table.FromList( Table[Cust No],Splitter.SplitByNothing(),null,null,ExtraValues.Error ) )), #"Expanded Cust" = Table.ExpandTableColumn(#"Added Custom", "Cust", {"Column1"}, {"Cust.Column1"}), #"Added Custom1" = Table.AddColumn(#"Expanded Cust", "Custom", each let date = [Delivered Date],cust=[Cust.Column1], tab = Table.SelectRows( Table, each [Delivered Date]=date and [Cust No]=cust )[Doc No] in tab ), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom1", "Custom"), #"Added Custom2" = Table.AddColumn(#"Expanded Custom", "Custom.1", each let date = [Delivered Date],cust=[Cust.Column1], c=[Custom], val = List.Sum( Table.SelectRows( Table, each [Delivered Date]=date and [Cust No]=cust and [Doc No]=c )[Vol] ) in if val=null then 0 else val ), #"Renamed Columns1" = Table.RenameColumns(#"Added Custom2",{{"Cust.Column1", "Cust No."}, {"Custom", "Doc No."}, {"Custom.1", "Vol"}}) in #"Renamed Columns1"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.
I think you should Create Customer & Date tables.
Create a measure of Volume that will return "0" if it is blank.
Then use Date & Customer from those tables and enable "Show items with No Data" in table or Matrix visual to get the desired results.
Hi
Thanks for the response.
I'm not sure if i got it correctly.
Do you mean i should separate out the Customer No. as a different table? and that will leave me with 3 tables (date, customer and delivery?)
How would you recommend I manage a relationship between these 3 tables.