title: Dynamic DAX Number Format
body: <p>I want to dynamically change the number format of a DAX measure, based on a dimension value (or indeed, based on the order of magnitude of the measure value).</p>
  
  <p>I understand I can use <code>SWITCH</code> and <code>FORMAT</code>, as demonstrated by Kaspar De Jonge here: <a href="https://www.kasperonbi.com/dynamic-format-using-dax/" rel="noreferrer">https://www.kasperonbi.com/dynamic-format-using-dax/</a></p>
  
  <p>Here's an example of the type of measure I'm creating:</p>
  
  <pre><code>My Measure:=IF ( 
      HASONEVALUE ( dimMeasureType[Measure Type] ), 
      SWITCH ( VALUES ( dimMeasureType[Measure Type] ),
          "Total Cost", FORMAT ( [Total Cost], "#,##0, k" ),
          "Cost Per Unit", FORMAT ( [Cost Per Unit], "#,##0.00" ),
          "Cost % Sales", FORMAT ( [Cost % Sales], "0.00%" ),
          BLANK()
      ),
      BLANK()
  )
  </code></pre>
  
  <p>But this technique returns <strong>text</strong> measures. I need to be able to chart my measures, so I do not want to convert them to text. Is there another technique for dynamically changing a measure number format, without converting to a string?</p>
  
  <p>If it makes a difference, I'm working in SSAS-Tabular on SQL Server 2016 BI.</p>