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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
RockliffeBI
Frequent Visitor

Power BI Notebooks - Persisting Variables Between Sessions

Hello, I'm trying to configure a Notebook to access some data from an API and save the resulting .json to a Datalakehouse.  It all works really nicely, but I want to configure it so that it polls the API only for data that I don't already have.  

 

I am setting a date range on the API call, using the current date at one end, at the other end I need to use the date that the notebook last successfully ran.  I can create that date in the Notebook, when it runs.  But is that value then available the next time the Notebook is run?

 

If it isn't, is there a simple alternative method to access that date, eg is the last run date available somewhere else or is do I ened to do something a bit hacky such as writing out the run date to another file in the Lakehouse that the Notebook can then pick up the date from the next time it runs?

 

Thanks!

1 REPLY 1
Anonymous
Not applicable

Hi @RockliffeBI ,

 

In Power BI Notebooks, by default, variables and their values are not retained between sessions.
To retain variables between notebook sessions, you can consider the following methods:
1. Use external storage:
Store the date of the last run in an external storage location, such as a file or database in Datalakehouse. On each run, read the stored date from the external location and then update it after a successful run. In this way, the notebook can always reference the last run date from the external storage.
2. Power BI Dataflow or Dataset:
If your Power BI environment allows it, you can create a dataflow or dataset in Power BI to store the last run date. The notebook can then query this dataflow or dataset to retrieve the last run date and update it accordingly.


Best Regards,
Adamk Kong

 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.