<?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: Fabric User Data Function parameter defaults? in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4760241#M10826</link>
    <description>&lt;P&gt;Thank you, that worked&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Jul 2025 15:07:11 GMT</pubDate>
    <dc:creator>MangoMagic</dc:creator>
    <dc:date>2025-07-11T15:07:11Z</dc:date>
    <item>
      <title>Fabric User Data Function parameter defaults?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4759361#M10809</link>
      <description>&lt;P&gt;Was trying to create a function which runs a stored proc and returns some results, is there a way to set default values in parameters, e.g. to make parameters optional and default them if no value is given?&lt;BR /&gt;&lt;BR /&gt;I tried following but it doesn't seem to work, the function doesn't even publish when I try and set default values&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;@udf.connection(argName="sqlDB",alias="Control")
@udf.function()
def GetWatermark(sqlDB: fn.FabricSqlConnection, ID: int, option: str = "Get watermark", description: str = None)-&amp;gt; list:
    option = option.lower()
    
    if option == "get watermark":
        query = "exec exec [dbo].[Get_ETLSettings] &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/339465"&gt;@ID&lt;/a&gt; = {ID}, @Option = '{option}';"

    #if option == "hour":

    # Establish a connection to the SQL database
    connection = sqlDB.connect()
    cursor = connection.cursor()

    # Execute the query
    cursor.execute(query)

    # Fetch all results
    results = []
    for row in cursor.fetchall():
        results.append(row)

    # Close the connection
    cursor.close()
    connection.close()
        
    return results&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jul 2025 20:52:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4759361#M10809</guid>
      <dc:creator>MangoMagic</dc:creator>
      <dc:date>2025-07-10T20:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric User Data Function parameter defaults?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4759870#M10814</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1269834"&gt;@MangoMagic&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thank you for contacting the Microsoft Fabric Community Forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently, Microsoft Fabric's Python User Defined Functions (UDFs) created with the @udf.function decorator do not allow default values or optional parameters in their definitions. If you try to set a default value for a parameter, such as option: str = "Get watermark", the function will not publish or compile correctly in the Fabric environment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To avoid issues, make sure all parameters are explicitly defined and provided when calling the function. If you need default behavior, handle it inside the function by checking if a parameter is empty or null and then assigning a value as needed. This method works within the platform's current limitations and ensures your UDFs will run as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;from microsoft.fabric import udf

import microsoft.fabric.functions as fn



@udf.connection(argName="sqlDB", alias="Control")

@udf.function()

def GetWatermark(sqlDB: fn.FabricSqlConnection, ID: int, option: str, description: str) -&amp;gt; list:

   

    if not option:

        option = "get watermark"

    else:

        option = option.lower()



    if option == "get watermark":

        query = f"EXEC [dbo].[Get_ETLSettings] @ID = {ID}, @Option = '{option}';"

    else:

      

        query = f"EXEC [dbo].[Get_ETLSettings] @ID = {ID}, @Option = '{option}';"



    connection = sqlDB.connect()

    cursor = connection.cursor()



    cursor.execute(query)

    results = cursor.fetchall()



    cursor.close()

    connection.close()



    return results&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Karpurapu D,&lt;/P&gt;
&lt;P&gt;Microsoft Fabric Community Support Team.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jul 2025 09:09:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4759870#M10814</guid>
      <dc:creator>v-karpurapud</dc:creator>
      <dc:date>2025-07-11T09:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric User Data Function parameter defaults?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4760241#M10826</link>
      <description>&lt;P&gt;Thank you, that worked&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jul 2025 15:07:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4760241#M10826</guid>
      <dc:creator>MangoMagic</dc:creator>
      <dc:date>2025-07-11T15:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric User Data Function parameter defaults?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4877684#M13502</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/883005"&gt;@v-karpurapud&lt;/a&gt;&amp;nbsp;I have a similar problem. In my use case, I am using UDF into powerbi report and passing the parameters through Text slicer. If I dont pass the value from pbi report, it doesn't enabled the button hence, I need to pass the all values irrespective it is required or not. Is there a workaround for same?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2025 15:00:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4877684#M13502</guid>
      <dc:creator>Sharmilshah</dc:creator>
      <dc:date>2025-11-17T15:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric User Data Function parameter defaults?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4879389#M13570</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/662111"&gt;@Sharmilshah&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;In Microsoft Fabric, Fabric UDFs require all parameters to be explicitly provided, and the Invoke Function visual in Power BI disables the button whenever any parameter evaluates to BLANK(). Because of this behavior, optional parameters or default values in the UDF signature are currently not supported.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;To work around this, keep all parameters mandatory in the UDF signature and implement any “optional/default” logic inside the function by checking whether a parameter is empty or null and assigning a default value as needed. On the Power BI side, ensure that measures mapped to UDF parameters never return BLANK(). This can be achieved using SELECTEDVALUE() with a fallback value or COALESCE() for numeric parameters. For example, return "Get watermark" when no option is selected and "" for optional text fields instead of BLANK().&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Microsoft Fabric Community Support Team.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 07:11:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-User-Data-Function-parameter-defaults/m-p/4879389#M13570</guid>
      <dc:creator>v-karpurapud</dc:creator>
      <dc:date>2025-11-19T07:11:26Z</dc:date>
    </item>
  </channel>
</rss>

