Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
paw1
Helper I
Helper I

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

 

paw1_0-1678375375598.png

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")

 

 

1 ACCEPTED SOLUTION
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.

RicoZhou_0-1678699353558.png

 

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.

View solution in original post

2 REPLIES 2
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.

RicoZhou_0-1678699353558.png

 

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.

paw1
Helper I
Helper I

@Anonymous Could you please help me on this logic

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors