<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Editing value of widget parameter within notebook code in Community Articles</title>
    <link>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/98112#M320</link>
    <description>&lt;P&gt;The code you have shared will not work. You can try for yourself.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2024 16:37:03 GMT</pubDate>
    <dc:creator>gauthamg</dc:creator>
    <dc:date>2024-11-07T16:37:03Z</dc:date>
    <item>
      <title>Editing value of widget parameter within notebook code</title>
      <link>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/64200#M17</link>
      <description>&lt;P&gt;I have a notebook with a text widget where I want to be able to edit the value of the widget within the notebook and then reference it in SQL code. For example, assuming there is a text widget named Var1 that has input value "Hello", I would want to be able to do the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;originalValue =&amp;nbsp;dbutils.widgets.get('Var1')&lt;/P&gt;&lt;P&gt;dbutils.widgets.text('Var1', originalValue + ", World!")&lt;/P&gt;&lt;P&gt;%sql&lt;/P&gt;&lt;P&gt;select '${Var1}' -&amp;gt; returns 'Hello, World!'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, whenever I try an approach like this in my notebooks, it does not update the value in Var1 and will select the original 'Hello' value. How can I fix this? Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 18:13:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/64200#M17</guid>
      <dc:creator>DavidOBrien</dc:creator>
      <dc:date>2024-03-20T18:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Editing value of widget parameter within notebook code</title>
      <link>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/69762#M74</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;The dbutils.widgets.text() function in Databricks takes three positional arguments. They are:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;name: The programmatic name of the text widget.&lt;/LI&gt;&lt;LI&gt;defaultValue: The default value of the text widget.&lt;/LI&gt;&lt;LI&gt;label: An optional label for the text widget.&lt;BR /&gt;From the above code you are trying to pass a default value, and you are already passing a value to widget var1, that's why the code always returns 'Hello'.&lt;BR /&gt;&lt;BR /&gt;I am not aware of a way to directly manipulate the value of widget, but the below code can help you to take the value from widget and then modify and use in the SQL.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Get the parameters
dbutils.widgets.text('param1',"Hello") #Default value as Hello
param1 = dbutils.widgets.get("param1")
# Printing value of param1 
print(f"Parameter 1: {param1}")
#manupualting the value using python
param1=param1+' World!'
print(param1)
#defining spark varaiable with value of modified variable param1 
spark.sql(f"set param1.var='{param1}'")

--------------

%sql
SELECT cast(${param1.var} as string)
​&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Hkesharwani_0-1716089413844.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/7726i4044C09961D5B501/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="Hkesharwani_0-1716089413844.png" alt="Hkesharwani_0-1716089413844.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 May 2024 03:30:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/69762#M74</guid>
      <dc:creator>Hkesharwani</dc:creator>
      <dc:date>2024-05-19T03:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Editing value of widget parameter within notebook code</title>
      <link>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/70143#M84</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/102601"&gt;@DavidOBrien&lt;/a&gt;, how are you?&lt;/P&gt;
&lt;P&gt;You can try the following approach:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Get the current value of the widget
current_value = dbutils.widgets.get("widget_name")

# Append the new value to the current value
new_value = current_value + "appended_value"

# Set the widget value with the updated string
dbutils.widgets.text("widget_name", new_value)&lt;/LI-CODE&gt;
&lt;P&gt;Please note that this will work if the widget is a text widget. If the widget is of a different type, you might need to convert the values to the appropriate type before appending and setting the new value.&lt;/P&gt;
&lt;P&gt;Let me know if it helps.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Alessandro&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 15:08:40 GMT</pubDate>
      <guid>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/70143#M84</guid>
      <dc:creator>anardinelli</dc:creator>
      <dc:date>2024-05-21T15:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Editing value of widget parameter within notebook code</title>
      <link>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/98112#M320</link>
      <description>&lt;P&gt;The code you have shared will not work. You can try for yourself.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 16:37:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/98112#M320</guid>
      <dc:creator>gauthamg</dc:creator>
      <dc:date>2024-11-07T16:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Editing value of widget parameter within notebook code</title>
      <link>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/119766#M433</link>
      <description>&lt;P&gt;I haven't been able to find a way to change the value of a widget except by removing it and re-creating.&lt;/P&gt;&lt;P&gt;originalValue =&amp;nbsp;dbutils.widgets.get('Var1')&lt;/P&gt;&lt;P&gt;dbutils.widgets.remove('Var1')&lt;/P&gt;&lt;P&gt;dbutils.widgets.text('Var1', originalValue + ", World!")&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 14:18:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/119766#M433</guid>
      <dc:creator>help_needed_445</dc:creator>
      <dc:date>2025-05-20T14:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Editing value of widget parameter within notebook code</title>
      <link>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/120424#M436</link>
      <description>&lt;P&gt;It seems that only way to use parameters in sql code block is to use dbutils.widget and you cannot change those parameters without removing widget and setting it up again in code&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2025 12:59:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/120424#M436</guid>
      <dc:creator>Ville_Leinonen</dc:creator>
      <dc:date>2025-05-28T12:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Editing value of widget parameter within notebook code</title>
      <link>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/134871#M727</link>
      <description>&lt;P&gt;I found I also have to do&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;dbutils.widgets.remove('Var1')&lt;/FONT&gt; in one cell and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;dbutils.widgets.text('Var1', originalValue + ", World!")&amp;nbsp;&lt;FONT face="arial,helvetica,sans-serif"&gt;in the next cell or it remembers the old value when it sets the widget back up.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Oct 2025 14:49:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/community-articles/editing-value-of-widget-parameter-within-notebook-code/m-p/134871#M727</guid>
      <dc:creator>GoToJDenman</dc:creator>
      <dc:date>2025-10-14T14:49:47Z</dc:date>
    </item>
  </channel>
</rss>

