This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
can I check how is it possible to exit a notebook gracefully with
Solved! Go to Solution.
Hi @tan_thiamhuat ,
Yeah, you can totally do that. If you use mssparkutils.notebook.exit inside a cell, it’ll stop the notebook right there and none of the cells below will run after that. Just put your condition check at the top of the cell, and call notebook.exit when you want to stop. For example:
if some_condition: mssparkutils.notebook.exit("Stopping execution because condition met") # whatever code below here won’t get executed if the exit is called
It doesn’t matter if you have more cells after, they just won’t be executed once exit runs. That’s how I usually handle early exits when I need to.
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.
Hi @tan_thiamhuat ,
Yeah, you can totally do that. If you use mssparkutils.notebook.exit inside a cell, it’ll stop the notebook right there and none of the cells below will run after that. Just put your condition check at the top of the cell, and call notebook.exit when you want to stop. For example:
if some_condition: mssparkutils.notebook.exit("Stopping execution because condition met") # whatever code below here won’t get executed if the exit is called
It doesn’t matter if you have more cells after, they just won’t be executed once exit runs. That’s how I usually handle early exits when I need to.
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.
Check out the June 2026 Fabric update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
| User | Count |
|---|---|
| 21 | |
| 17 | |
| 15 | |
| 11 | |
| 11 |