Forum Discussion

paw1's avatar
paw1
Helper I
3 years ago
Solved

If logic help

Hi,

Can any one please help me to derive below Type Flag as column from Main Num and Alternate Number based on below logic.

 

if Main Num not repeated in Alternate Number then it's parent
if Main Num is repeated in Alternate Number and also Alternate Number is repeated in Main Number then it's Child- Parent
if Main Num is repeated in Alternate Number and Alternate Number is not repeated in Main Number then it's Child

 

i have tried below custom column in power query but it's not working for all above three conditions.

 #"Added Custom" = Table.AddColumn(#"Filled Down", "Flag", each if List.Contains(#"Filled Down"[number],[associated number]) then "Parent" else "Child")

 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi paw1 ,

     

    I think you can try this code to create a custom column.

    let 
    _MainNum = #"Changed Type"[Main Num],
    _AltNum = #"Changed Type"[Alternate Number]
    in
    if List.Contains(_AltNum,[Main Num]) 
    then
    if List.Contains(_MainNum,[Alternate Number]) 
    then "Child- Parent" else "Child"
    else "Parent"

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous Could you please help me on this logic

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi paw1 ,

     

    I think you can try this code to create a custom column.

    let 
    _MainNum = #"Changed Type"[Main Num],
    _AltNum = #"Changed Type"[Alternate Number]
    in
    if List.Contains(_AltNum,[Main Num]) 
    then
    if List.Contains(_MainNum,[Alternate Number]) 
    then "Child- Parent" else "Child"
    else "Parent"

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.