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.
Hi,
I'm working with parent-child hierarchy and I want do to do something but I'm not sure if it's possible.
Here an example of what I'm trying to do :
There are 4 columns : ID, parent ID, Process and the path determinated by the DAX function.
I've added a new column which evaluate if Process= "Freezing
Now I want to add a new column, if Isfreezing= true then "A" but I want that the other processes that belong to the hierarchy also to get "A". So I don't know which DAX function I have to use to finally have this result :
Thanks !
Solved! Go to Solution.
let
REC = (l as list, id) as list =>
if id is null then l else
let
p = List.PositionOf(Sup, id)
in if p<>-1 then @REC(l & {id}, Init{p}) else l & {id},
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQKiCqVYnWglIyALJFAJ5hlDeVVgngmQBZIvB/NMgSyQiFtRampVZl46WNAMKpgG5pkDWSAjisE8QwOIRfkQi0A8sBCKAcYgEbBcIcROOD8ZYiuICRYsU4qNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, ID_INIT = _t, PROCESS = _t]),
Sup = Source[ID],
Init = Source[ID_INIT],
#"Added Path" = Table.AddColumn(Source, "Path", each {[ID]} & REC({}, [ID_INIT])),
#"ID Freezing" = let id = #"Added Path"[ID] in List.Transform(List.PositionOf(#"Added Path"[PROCESS], "Freezing", 2), each id{_}),
#"All Freezing" = List.Distinct(List.Combine(List.Select(#"Added Path"[Path], each List.Count(List.Intersect({_, #"ID Freezing"}))>0))),
#"Replaced Value" = Table.ReplaceValue(#"Added Path", each [Path], each if List.Contains(#"All Freezing", [ID]) then "A" else "", Replacer.ReplaceValue, {"Path"})
in
#"Replaced Value"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
let
REC = (l as list, id) as list =>
if id is null then l else
let
p = List.PositionOf(Sup, id)
in if p<>-1 then @REC(l & {id}, Init{p}) else l & {id},
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQKiCqVYnWglIyALJFAJ5hlDeVVgngmQBZIvB/NMgSyQiFtRampVZl46WNAMKpgG5pkDWSAjisE8QwOIRfkQi0A8sBCKAcYgEbBcIcROOD8ZYiuICRYsU4qNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, ID_INIT = _t, PROCESS = _t]),
Sup = Source[ID],
Init = Source[ID_INIT],
#"Added Path" = Table.AddColumn(Source, "Path", each {[ID]} & REC({}, [ID_INIT])),
#"ID Freezing" = let id = #"Added Path"[ID] in List.Transform(List.PositionOf(#"Added Path"[PROCESS], "Freezing", 2), each id{_}),
#"All Freezing" = List.Distinct(List.Combine(List.Select(#"Added Path"[Path], each List.Count(List.Intersect({_, #"ID Freezing"}))>0))),
#"Replaced Value" = Table.ReplaceValue(#"Added Path", each [Path], each if List.Contains(#"All Freezing", [ID]) then "A" else "", Replacer.ReplaceValue, {"Path"})
in
#"Replaced Value"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |