<?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: User Defined Function - Dynamic Formatting in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Defined-Function-Dynamic-Formatting/m-p/4859773#M185374</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1374520" data-lia-user-login="christsup3r" class="lia-mention lia-mention-user"&gt;christsup3r&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;May I ask if you have resolved this issue? Please let us know if you have any further issues, we are happy to help.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Oct 2025 16:21:58 GMT</pubDate>
    <dc:creator>v-echaithra</dc:creator>
    <dc:date>2025-10-27T16:21:58Z</dc:date>
    <item>
      <title>User Defined Function - Dynamic Formatting</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Defined-Function-Dynamic-Formatting/m-p/4852359#M185200</link>
      <description>&lt;P&gt;Hi All, is there a way to create a function that will work on dynamic formatting? it seems like you cannot run calculations if you are going to use it within dynamic formatting. I have this code.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DEFINE 
    FUNCTION Fn_Formatting = (_Measure, _FormatType, _Scale) =&amp;gt;

    VAR v = _Measure
    
    VAR Result = 
        SWITCH(
            TRUE(),
            // Amounts with Scale
            _FormatType = "Amounts" &amp;amp;&amp;amp; _Scale = "B", "$" &amp;amp; FORMAT(DIVIDE(v, 1e9), "#,0.0") &amp;amp; "B",
            _FormatType = "Amounts" &amp;amp;&amp;amp; _Scale = "M", "$" &amp;amp; FORMAT(DIVIDE(v, 1e6), "#,0.0") &amp;amp; "M",
            _FormatType = "Amounts" &amp;amp;&amp;amp; _Scale = "K", "$" &amp;amp; FORMAT(DIVIDE(v, 1e3), "#,0.0") &amp;amp; "K",
            _FormatType = "Amounts", "$" &amp;amp; FORMAT(v, "#,0.0"),
            
            // Numbers with Scale
            _FormatType = "Numbers" &amp;amp;&amp;amp; _Scale = "B", FORMAT(DIVIDE(v, 1e9), "#,0.0") &amp;amp; "B",
            _FormatType = "Numbers" &amp;amp;&amp;amp; _Scale = "M", FORMAT(DIVIDE(v, 1e6), "#,0.0") &amp;amp; "M",
            _FormatType = "Numbers" &amp;amp;&amp;amp; _Scale = "K", FORMAT(DIVIDE(v, 1e3), "#,0.0") &amp;amp; "K",
            _FormatType = "Numbers", FORMAT(v, "#,0.0"),
            
            // Default
            FORMAT(v, "#,0.0")
        )
    RETURN
        Result&lt;/LI-CODE&gt;&lt;P&gt;is there a work around on this?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Oct 2025 03:01:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Defined-Function-Dynamic-Formatting/m-p/4852359#M185200</guid>
      <dc:creator>christsup3r</dc:creator>
      <dc:date>2025-10-17T03:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: User Defined Function - Dynamic Formatting</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Defined-Function-Dynamic-Formatting/m-p/4852480#M185206</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1374520" data-lia-user-login="christsup3r" class="lia-mention lia-mention-user"&gt;christsup3r&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, a format string expression should return a format string, rather than the result of formatting a value with a format string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case, if you're wanting format strings to be set based on &lt;STRONG&gt;_FormatType&lt;/STRONG&gt; and &lt;STRONG&gt;_Scale&lt;/STRONG&gt; parameters, you could rewrite your function as follows (I've made some simplifications as well):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DEFINE 
FUNCTION Fn_Formatting = ( _FormatType, _Scale ) =&amp;gt;
VAR CurrencySymbol =
    SWITCH (
        _FormatType,
        "Amounts", "$",
        ""
    )
VAR NumScaleCommas = SWITCH (
        _Scale,
        "B", 3,
        "M", 2,
        "K", 1,
        0
    )
VAR ScaleCommas = REPT ( ",", NumScaleCommas )
VAR FinalFormatString =
    CurrencySymbol &amp;amp; "#,0" &amp;amp; ScaleCommas &amp;amp; ".0" &amp;amp; "\"
        &amp;amp; _Scale
RETURN
    FinalFormatString&lt;/LI-CODE&gt;
&lt;P&gt;Then you could set the dynamic format string of a particular measure to be an expression like any of these:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Fn_Formatting ( "Amount", "K" )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Fn_Formatting ( "Numbers", "M" )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this work for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See &lt;A href="https://www.linkedin.com/posts/kurtbuhler_powerbi-dax-tabulareditor-activity-7374443068227469312-Kq4l?utm_source=share&amp;amp;utm_medium=member_desktop&amp;amp;rcm=ACoAAA9yMQQBMgrj40n7YsHJxKDuhTSzWfH7Cik" target="_blank" rel="noopener"&gt;this post&lt;/A&gt; for some further demonstrations of UDFs applied to format strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Oct 2025 06:45:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Defined-Function-Dynamic-Formatting/m-p/4852480#M185206</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2025-10-17T06:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: User Defined Function - Dynamic Formatting</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Defined-Function-Dynamic-Formatting/m-p/4856561#M185291</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1374520" data-lia-user-login="christsup3r" class="lia-mention lia-mention-user"&gt;christsup3r&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp; for your inputs.&lt;/P&gt;
&lt;P&gt;We’d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Chaithra E.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2025 07:19:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Defined-Function-Dynamic-Formatting/m-p/4856561#M185291</guid>
      <dc:creator>v-echaithra</dc:creator>
      <dc:date>2025-10-23T07:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: User Defined Function - Dynamic Formatting</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Defined-Function-Dynamic-Formatting/m-p/4859773#M185374</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1374520" data-lia-user-login="christsup3r" class="lia-mention lia-mention-user"&gt;christsup3r&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;May I ask if you have resolved this issue? Please let us know if you have any further issues, we are happy to help.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2025 16:21:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Defined-Function-Dynamic-Formatting/m-p/4859773#M185374</guid>
      <dc:creator>v-echaithra</dc:creator>
      <dc:date>2025-10-27T16:21:58Z</dc:date>
    </item>
  </channel>
</rss>

