<?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: FORMAT function with standard string and 1 decimal digit in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FORMAT-function-with-standard-string-and-1-decimal-digit/m-p/2214013#M52330</link>
    <description>&lt;P&gt;Yes that's the idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest you use variables to avoid evaluating the same measure(s) multiple times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code I posted earlier was what I was thinking as far as structure:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Store the measure itself in one variable MeasureValue (T_01, T02 etc).&lt;/LI&gt;
&lt;LI&gt;Then store the chosen format string in a second variable&lt;/LI&gt;
&lt;LI&gt;Finally, format the measure using the format string&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Tue, 30 Nov 2021 12:51:20 GMT</pubDate>
    <dc:creator>OwenAuger</dc:creator>
    <dc:date>2021-11-30T12:51:20Z</dc:date>
    <item>
      <title>FORMAT function with standard string and 1 decimal digit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FORMAT-function-with-standard-string-and-1-decimal-digit/m-p/2213771#M52310</link>
      <description>&lt;P&gt;I have a pivot table and for the calculation of the values i am using a switch statement. For each different row i have a different calculation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code of each row is like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SWITCH(SELECTEDVALUE(v_raw_data[metric_code]),
     "T_01",FORMAT([T_01],SELECTEDVALUE(v_raw_data[value_formatter])),
     BLANK())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the value_formatter i am using the standard string list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PREDEFINED NUMERIC FORMATS Format Description&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;"General Number"&lt;/TD&gt;&lt;TD&gt;Displays number with no thousand separators.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"Currency"&lt;/TD&gt;&lt;TD&gt;Displays number with thousand separators, if appropriate; displays two digits to the right of the decimal separator. Output is based on system locale settings.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"Fixed"&lt;/TD&gt;&lt;TD&gt;Displays at least one digit to the left and two digits to the right of the decimal separator.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"Standard"&lt;/TD&gt;&lt;TD&gt;Displays number with thousand separators, at least one digit to the left and two digits to the right of the decimal separator.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"Percent"&lt;/TD&gt;&lt;TD&gt;Displays number multiplied by 100 with a percent sign (%) appended immediately to the right; always displays two digits to the right of the decimal separator.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"Scientific"&lt;/TD&gt;&lt;TD&gt;Uses standard scientific notation, providing two significant digits.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"Yes/No"&lt;/TD&gt;&lt;TD&gt;Displays No if number is 0; otherwise, displays Yes.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"True/False"&lt;/TD&gt;&lt;TD&gt;Displays False if number is 0; otherwise, displays True.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;"On/Off"&lt;/TD&gt;&lt;TD&gt;Displays Off if number is 0; otherwise, displays On.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the way that this works if decimals exist then i always get 2 decimals. Else i have integers. I am giving you also i picture&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can i change it to give me if we have decimals only one. But not all values to have one decimal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In another way if i have these two function:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;1) FORMAT ( 5, "0.#" ) 
2) FORMAT ( 0.56, "0.#" ) &lt;/LI-CODE&gt;&lt;P&gt;How can i succeed with a result of&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;1) 5
2) 0.6&lt;/LI-CODE&gt;&lt;P&gt;with the same String format.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 11:29:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FORMAT-function-with-standard-string-and-1-decimal-digit/m-p/2213771#M52310</guid>
      <dc:creator>kyrpav</dc:creator>
      <dc:date>2021-11-30T11:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: FORMAT function with standard string and 1 decimal digit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FORMAT-function-with-standard-string-and-1-decimal-digit/m-p/2213926#M52320</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="187020" data-lia-user-login="kyrpav" class="lia-mention lia-mention-user"&gt;kyrpav&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't believe there is any solution involving a single format string that will show integers with no decimal point/places, but otherwise show a decimal point &amp;amp; one decimal place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would say the other options are either:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Add an additional column to your v_raw_data table that specifies format strings for integers, e.g. add a column &lt;STRONG&gt;v_raw_data[value_formatter_integer]&lt;/STRONG&gt;.&lt;BR /&gt;Then change your DAX expression so that it uses this new column for integers. Something like this (with a bit of re-jigging as well):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VAR MetricValue = 
    SWITCH (
        SELECTEDVALUE( v_raw_data[metric_code] ),
        "T_01", [T_01],
        //...
        BLANK ()
    )
VAR FormatString = 
    IF (
        MetricValue = TRUNC ( MetricValue ), -- integer
        SELECTEDVALUE ( v_raw_data[value_formatter_integer] ),
        SELECTEDVALUE ( v_raw_data[value_formatter] )
    )
RETURN
    FORMAT ( MetricValue, FormatString )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Alternatively, you could do something with calculation group format strings.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/controlling-format-strings-in-calculation-groups/" target="_blank"&gt;https://www.sqlbi.com/articles/controlling-format-strings-in-calculation-groups/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 11:49:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FORMAT-function-with-standard-string-and-1-decimal-digit/m-p/2213926#M52320</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2021-11-30T11:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: FORMAT function with standard string and 1 decimal digit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FORMAT-function-with-standard-string-and-1-decimal-digit/m-p/2213963#M52326</link>
      <description>&lt;P&gt;I was thinking the same thing if i understand well to do it like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;switch(selectedvalue(v_raw_data[metric_code]), 
"T_02",if(TRUNC([T_02])=[T_02],FORMAT([T_02],SELECTEDVALUE(v_raw_data[value_formatter])),FORMAT([T_02],"##0.0")) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but i did not like to run the same function too many times. What you propose to split it also i think is better.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 12:11:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FORMAT-function-with-standard-string-and-1-decimal-digit/m-p/2213963#M52326</guid>
      <dc:creator>kyrpav</dc:creator>
      <dc:date>2021-11-30T12:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: FORMAT function with standard string and 1 decimal digit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FORMAT-function-with-standard-string-and-1-decimal-digit/m-p/2214013#M52330</link>
      <description>&lt;P&gt;Yes that's the idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest you use variables to avoid evaluating the same measure(s) multiple times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code I posted earlier was what I was thinking as far as structure:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Store the measure itself in one variable MeasureValue (T_01, T02 etc).&lt;/LI&gt;
&lt;LI&gt;Then store the chosen format string in a second variable&lt;/LI&gt;
&lt;LI&gt;Finally, format the measure using the format string&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 30 Nov 2021 12:51:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/FORMAT-function-with-standard-string-and-1-decimal-digit/m-p/2214013#M52330</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2021-11-30T12:51:20Z</dc:date>
    </item>
  </channel>
</rss>

