<?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 Custom Visual - Display Units - Auto not working in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Display-Units-Auto-not-working/m-p/2832357#M39164</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I installed the formatting utils from here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/microsoft/powerbi-visuals-utils-formattingutils" target="_blank" rel="noopener"&gt;https://github.com/microsoft/powerbi-visuals-utils-formattingutils&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I added `&lt;/P&gt;&lt;P&gt;(to the capabilities.json)&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;"displayUnit": {
					"displayName": "Display Units",
					"description": "Specify display unit.",
					"type": {
						"formatting": {
							"labelDisplayUnits": true
						}
					}
				},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the visual i added:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const formatter: IValueFormatter = valueFormatter.create({
                value: this.visualSettings.value.displayUnit,
                precision: this.visualSettings.value.measurePrecision,
                cultureSelector: "en-US"
            });

formatter.format(value);&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;This seems to work perfectly if i change the drop down to Thousands, Millions etc. but doesnt seem to do anything if i set it to auto.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the same setting on the default MS Card and with auto set and the value changes to 119.42K but in my custom card it stays at 119416. If i set the dropdown to thousands in my custom card&amp;nbsp; it shows at 119.42k (like auto on the official card).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something special I have to do in my code for the auto to work?&lt;BR /&gt;I believe auto sends back a value of 0 for&amp;nbsp;&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;visualSettings&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;value&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;displayUnit which doesnt seem to do anything and 1000 for thousands which works, the MS doc site for this also doesnt mention auto:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/utils-formatting" target="_blank"&gt;https://learn.microsoft.com/en-us/power-bi/developer/visuals/utils-formatting&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adam&lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2022 03:57:52 GMT</pubDate>
    <dc:creator>AdamWhittaker</dc:creator>
    <dc:date>2022-10-11T03:57:52Z</dc:date>
    <item>
      <title>Custom Visual - Display Units - Auto not working</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Display-Units-Auto-not-working/m-p/2832357#M39164</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I installed the formatting utils from here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/microsoft/powerbi-visuals-utils-formattingutils" target="_blank" rel="noopener"&gt;https://github.com/microsoft/powerbi-visuals-utils-formattingutils&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I added `&lt;/P&gt;&lt;P&gt;(to the capabilities.json)&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;"displayUnit": {
					"displayName": "Display Units",
					"description": "Specify display unit.",
					"type": {
						"formatting": {
							"labelDisplayUnits": true
						}
					}
				},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the visual i added:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const formatter: IValueFormatter = valueFormatter.create({
                value: this.visualSettings.value.displayUnit,
                precision: this.visualSettings.value.measurePrecision,
                cultureSelector: "en-US"
            });

formatter.format(value);&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;This seems to work perfectly if i change the drop down to Thousands, Millions etc. but doesnt seem to do anything if i set it to auto.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the same setting on the default MS Card and with auto set and the value changes to 119.42K but in my custom card it stays at 119416. If i set the dropdown to thousands in my custom card&amp;nbsp; it shows at 119.42k (like auto on the official card).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something special I have to do in my code for the auto to work?&lt;BR /&gt;I believe auto sends back a value of 0 for&amp;nbsp;&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;visualSettings&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;value&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;displayUnit which doesnt seem to do anything and 1000 for thousands which works, the MS doc site for this also doesnt mention auto:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/utils-formatting" target="_blank"&gt;https://learn.microsoft.com/en-us/power-bi/developer/visuals/utils-formatting&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adam&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 03:57:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Display-Units-Auto-not-working/m-p/2832357#M39164</guid>
      <dc:creator>AdamWhittaker</dc:creator>
      <dc:date>2022-10-11T03:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visual - Display Units - Auto not working</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Display-Units-Auto-not-working/m-p/2834994#M39194</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/442720"&gt;@AdamWhittaker&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;It's been a while since I've looked into this (I've been looking for some code where I've resolved it that I could copy/paste in here but don't have anything to hand), so I'm working from memory (and hopefully it might be close to correct).&lt;/P&gt;
&lt;P&gt;If you want auto formatting to work, I believe you'll need to substitute the measure value into the &lt;FONT face="courier new,courier"&gt;value&lt;/FONT&gt; property when &lt;FONT face="courier new,courier"&gt;displayUnit&lt;/FONT&gt; is 0, as this property represents the scale that Power BI needs to consider when formatting.&lt;/P&gt;
&lt;P&gt;Based on your example, something like the following should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;const formatter: IValueFormatter = valueFormatter.create({
    value: this.visualSettings.value.displayUnit || value,
    precision: this.visualSettings.value.measurePrecision,
    cultureSelector: "en-US"
});

formatter.format(value);
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This change (on line 2) will coalesce the &lt;FONT face="courier new,courier"&gt;displayUnit&lt;/FONT&gt; (which would be &lt;FONT face="courier new,courier"&gt;0&lt;/FONT&gt; if &lt;FONT face="courier new,courier"&gt;auto&lt;/FONT&gt;) to the measure value, which would then be used to derive whether the value should be formatted as none, thousands, millions etc.&lt;/P&gt;
&lt;P&gt;This would be equaivalent to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;const formatter: IValueFormatter = valueFormatter.create({
    value: this.visualSettings.value.displayUnit !== 0 ? this.visualSettings.value.displayUnit : value,
    precision: this.visualSettings.value.measurePrecision,
    cultureSelector: "en-US"
});

formatter.format(value);
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 20:49:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Display-Units-Auto-not-working/m-p/2834994#M39194</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2022-10-11T20:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visual - Display Units - Auto not working</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Display-Units-Auto-not-working/m-p/2835096#M39195</link>
      <description>&lt;P&gt;Thank you very much for the info, that worked great. Now i understand what the documentation was trying to communicate; their docs mention to pass 1001 for K and i just assumed it was a typo and they meant 1000 (which is mentioned lower down).. but they were just demonstrating that 1001 would automatically be converted for you (i think they should explain that)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 21:44:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Visual-Display-Units-Auto-not-working/m-p/2835096#M39195</guid>
      <dc:creator>AdamWhittaker</dc:creator>
      <dc:date>2022-10-11T21:44:29Z</dc:date>
    </item>
  </channel>
</rss>

