Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I am unable to delete this post. Please assist.
Solved! Go to Solution.
Hi @Mark-JZ-Yeap ,
Try this M code (not DAX) in a new blank query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZY5LEsAgCEPvwtoZAv7aszje/xoVtY62O5IXAqWQkCO9GJkVqiYi4zbhm6DqCnXXb64HixwRG6AsWO4EYcQRXyC/+jiP6orgG0ljUXSrD51kOxz3d1pZJ5eRdO5QrQ8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Employee ID" = _t, DOJ = _t, DOL = _t, ContinuedFor = _t]),
chgTypes = Table.TransformColumnTypes(Source,{{"DOJ", type date}, {"DOL", type date}, {"ContinuedFor", Int64.Type}, {"Employee ID", Int64.Type}}),
// Relevant steps from here =====>
mergeOnSelf = Table.NestedJoin(chgTypes, {"Employee ID"}, chgTypes, {"ContinuedFor"}, "nextEmp", JoinKind.LeftOuter),
expandDOJ = Table.ExpandTableColumn(mergeOnSelf, "nextEmp", {"DOJ"}, {"DOL_Updated"}),
repDOL_Updated = Table.ReplaceValue(expandDOJ, each [DOL_Updated], each if [DOL_Updated] > [DOL] then Date.EndOfMonth(Date.AddMonths([DOL_Updated], -1)) else null, Replacer.ReplaceValue,{"DOL_Updated"})
in
repDOL_Updated
Summary:
mergeOnSelf = Left outer merge the table on itself as [Employee ID] = [ContinuedFor].
expandDOJ = Expand the [DOJ] column from the nested table column (I also renamed it to DOL_Updated at the same time).
repDOL_Updated = Perform a conditional replace on the [DOL_Updated] column applying the required logic.
Example code turns this:
...into this:
Pete
Proud to be a Datanaut!
Hi @Mark-JZ-Yeap ,
Try this M code (not DAX) in a new blank query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZY5LEsAgCEPvwtoZAv7aszje/xoVtY62O5IXAqWQkCO9GJkVqiYi4zbhm6DqCnXXb64HixwRG6AsWO4EYcQRXyC/+jiP6orgG0ljUXSrD51kOxz3d1pZJ5eRdO5QrQ8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Employee ID" = _t, DOJ = _t, DOL = _t, ContinuedFor = _t]),
chgTypes = Table.TransformColumnTypes(Source,{{"DOJ", type date}, {"DOL", type date}, {"ContinuedFor", Int64.Type}, {"Employee ID", Int64.Type}}),
// Relevant steps from here =====>
mergeOnSelf = Table.NestedJoin(chgTypes, {"Employee ID"}, chgTypes, {"ContinuedFor"}, "nextEmp", JoinKind.LeftOuter),
expandDOJ = Table.ExpandTableColumn(mergeOnSelf, "nextEmp", {"DOJ"}, {"DOL_Updated"}),
repDOL_Updated = Table.ReplaceValue(expandDOJ, each [DOL_Updated], each if [DOL_Updated] > [DOL] then Date.EndOfMonth(Date.AddMonths([DOL_Updated], -1)) else null, Replacer.ReplaceValue,{"DOL_Updated"})
in
repDOL_Updated
Summary:
mergeOnSelf = Left outer merge the table on itself as [Employee ID] = [ContinuedFor].
expandDOJ = Expand the [DOJ] column from the nested table column (I also renamed it to DOL_Updated at the same time).
repDOL_Updated = Perform a conditional replace on the [DOL_Updated] column applying the required logic.
Example code turns this:
...into this:
Pete
Proud to be a Datanaut!
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.