This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
Hello All,
I'm brainstorming ideas on how to run recursion in Power BI and wanted community input.
High level, I need to display all the orders of a specific item/lot-number but this includes orders of this item and all the finishedgood BOMs that this lot is a part of. Unfortunately, the new Finished Good can be part of another completely different BOM. Thus recursion is necessary to out put all the relevant orders connected to a specific lot since this parent child relationship can go multiple levels.
So I have a table of all orders and a table of these BOMs
I don't think I can do this in Power BI but I think I can figure this out using Python.
If I used python, how would I embed this solution into a report?
Ideally, the user would use a slicer and choose specific lot then the python visual would use recursion and display a table of all the relevant orders. The user can then download the report.
Is this approach possible and are there any other potential solutions?
Solved! Go to Solution.
HI @mat33delo ,
Power BI does not natively support recursion, but you can achieve this using one of three methods:
Use DAX Parent-Child Hierarchy functions to track relationships.
BOM_Path = PATH(BOM[Child_Item], BOM[Parent_Item])
Is_Relevant_Order =
IF(PATHCONTAINS(BOM[BOM_Path], SELECTEDVALUE(Orders[Lot_Number])), 1, 0)
Use Python inside Power BI to handle multi-level recursion dynamically.
def find_orders(df, lot_number, bom_df):
related_orders = set()
def recurse(lot):
children = bom_df[bom_df['Parent_Item'] == lot]['Child_Item'].tolist()
related_orders.update(children)
for child in children:
recurse(child)
recurse(lot_number)
return df[df['Lot_Number'].isin(related_orders)]
selected_lot = dataset['Lot_Number'].iloc[0] # Get selected slicer value
result_df = find_orders(dataset, selected_lot, bom_data)
result_df
If real-time recursion is not required, precompute the hierarchy using Power Query (M).
HI @mat33delo ,
Power BI does not natively support recursion, but you can achieve this using one of three methods:
Use DAX Parent-Child Hierarchy functions to track relationships.
BOM_Path = PATH(BOM[Child_Item], BOM[Parent_Item])
Is_Relevant_Order =
IF(PATHCONTAINS(BOM[BOM_Path], SELECTEDVALUE(Orders[Lot_Number])), 1, 0)
Use Python inside Power BI to handle multi-level recursion dynamically.
def find_orders(df, lot_number, bom_df):
related_orders = set()
def recurse(lot):
children = bom_df[bom_df['Parent_Item'] == lot]['Child_Item'].tolist()
related_orders.update(children)
for child in children:
recurse(child)
recurse(lot_number)
return df[df['Lot_Number'].isin(related_orders)]
selected_lot = dataset['Lot_Number'].iloc[0] # Get selected slicer value
result_df = find_orders(dataset, selected_lot, bom_data)
result_df
If real-time recursion is not required, precompute the hierarchy using Power Query (M).
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 30 | |
| 21 | |
| 16 |
| User | Count |
|---|---|
| 62 | |
| 51 | |
| 31 | |
| 23 | |
| 23 |