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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
tan_thiamhuat
Helper V
Helper V

Notebook in Pipeline to trigger next flow, based on condition in the dataframe's column

I want to implement something like this:

In a Notebook, there is a dataframe DF with its column name 'Success'. If the sum(DF$success)>0, then I want to trigger the next flow.

Can someone show how to implement this?

1 ACCEPTED SOLUTION
burakkaragoz
Community Champion
Community Champion

Hi @tan_thiamhuat ,

 

Yep, you can do this in your notebook by checking the sum of the 'Success' column and then using mssparkutils.notebook.exit to pass a value back to the pipeline. Here’s an example in PySpark:

Python
 
success_sum = DF.selectExpr("sum(Success)").collect()[0][0]
if success_sum > 0:
    mssparkutils.notebook.exit("trigger_next")
else:
    mssparkutils.notebook.exit("do_not_trigger")

In your pipeline flow, you can use the output value from the notebook activity to decide whether to trigger the next activity/flow or not. Just set up a conditional check in the pipeline based on the notebook’s output string.

Let me know if you need more details or some other way to handle it.

If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.

View solution in original post

2 REPLIES 2
burakkaragoz
Community Champion
Community Champion

Hi @tan_thiamhuat ,

 

Yep, you can do this in your notebook by checking the sum of the 'Success' column and then using mssparkutils.notebook.exit to pass a value back to the pipeline. Here’s an example in PySpark:

Python
 
success_sum = DF.selectExpr("sum(Success)").collect()[0][0]
if success_sum > 0:
    mssparkutils.notebook.exit("trigger_next")
else:
    mssparkutils.notebook.exit("do_not_trigger")

In your pipeline flow, you can use the output value from the notebook activity to decide whether to trigger the next activity/flow or not. Just set up a conditional check in the pipeline based on the notebook’s output string.

Let me know if you need more details or some other way to handle it.

If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.

I have this two conditions:

## when there is CSV file to be processed

mssparkutils.notebook.exit("Cleaned CSV File generated at /primary/CleanedData in SFTP Server.")
## when there is NO CSV file to be processed
mssparkutils.notebook.exit("No CSV files to be processed.")
 
And I put the condition in the if loop as below:
tan_thiamhuat_0-1749800928023.png

It always go to the False loop, even if there is CSV file available to be processed. Is my logic correct?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.