I have
ds = Dataset@*
Map[AssociationThread[{"ID", "Date", "A"} -> #] &]@{{"C12",
SQLDateTime[{2012, 12, 11, 0, 0, 0.}], 10}, {"C12",
SQLDateTime[{2015, 2, 19, 19, 30, 0.}], 9},
{"C12", SQLDateTime[{2013, 1, 22, 0, 0, 0.}], 12}, {"C10",
SQLDateTime[{2013, 1, 28, 9, 25, 0.}], 15}, {"C10",
SQLDateTime[{2014, 3, 21, 20, 0, 0.}], 12}, {"C11",
SQLDateTime[{2014, 8, 27, 6, 40, 0.}], 8}}
and
ds2 = Dataset@*
Map[AssociationThread[{"ID", "Date", "B"} -> #] &]@{{"C10",
SQLDateTime[{2013, 1, 28, 0, 25, 0.}], 315},
{"C12", SQLDateTime[{2012, 10, 10, 0, 0, 0.}], 10}}
I combine them via
ds3 = SortBy["ID"]@JoinAcross[ds, ds2, {"ID", "Date"}, "Outer"]
Now, I replace the Missing["Unmatched"]
values B by the values from the lines above.
Module[{prev = Missing["Unmatched"]},
rfunc[Missing["Unmatched"]] := prev;
rfunc[b_] := prev = b;
ds3[All, {"B" -> rfunc}]]
But I have the problem, that I only want to do this in case, the ID is the same as in the line above (line with same ID but value for B existing). This means in line 4 (ID == C11) I'd like to have still an "Unmatched" instead of the 315, since the row above is corresponding to ID C10 instead of C11.
I would be very happy, if anybody could give me a hint. All I could think about so far didn't work and I have to present my data tomorrow ;-)