Forum Discussion
Anonymous
6 years agoNot applicable
Need help in merging data
Hi All, Actually im struggling in below case where date needs to be added to all rows of key value of first col that is MST_TO MST_TO Transport_Order__c 07_Order Booking date 11_Order D...
- 6 years agoYou might still be able to do this with Fill Down if you sort on MST_TO and Date columns first, otherwise see if this does what you need:
My thinking is to group by item, find the MAX Date for each item, then merge back into table. You could possibly create a custom function to do this for you, but here is the M code for the sample data I created to do this. You will need to paste this into three blank queries in Advanced Editor and name the tables as below to see it in action.
RawData
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUVKK1YEwDBW8SnMqdRSMDIwM4IKoDCdkhpEBugYnrOqUYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Item = _t, Date = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Item", type text}, {"Date", type date}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1)
in
#"Added Index"
FillDate
let
Source = RawData,
#"Grouped Rows" = Table.Group(Source, {"Item"}, {{"Date", each List.Max([Date]), type date}})
in
#"Grouped Rows"
Merge1
let
Source = Table.NestedJoin(RawData, {"Item"}, FillDate, {"Item"}, "FillDate", JoinKind.LeftOuter),
#"Expanded FillDate" = Table.ExpandTableColumn(Source, "FillDate", {"Date"}, {"Date.1"})
in
#"Expanded FillDate"
lbendlin
6 years agoSuper User
In Power Query there is a transform for that, called "Fill Down". Depending on your data you might also need to add a "Fill Up" step.
- Anonymous6 years agoNot applicable
that would not solve the problem here as it fills up all the below or above columns irrespective of first column as key value consideration
- AllisonKennedy6 years agoCommunity ChampionYou can sort by first column, then try fill down? We need more info here to help you.
- Anonymous6 years agoNot applicable
Hi Allison,
Thanks for checking my concerns
Fill up or fill down will wrongly fills up the data where it should not.
what i want is to have all the date values in all the rows corresponding to only first column only. not to other key.
in my example AAA as MST_TO rows should contain all the dates in all three rows in their rows only