<?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 Eliminate &amp;quot;hard coding&amp;quot;. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Eliminate-quot-hard-coding-quot/m-p/901475#M8246</link>
    <description>&lt;P&gt;Example table:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I am producing a pie chart to show the relationship of total payments for each category. I have four measures (one for each category).&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cat A = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE(&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;SUM(&amp;nbsp; 'Table'[Payment]&amp;nbsp; ),&lt;/SPAN&gt;&lt;SPAN&gt;' Table'[Category] = "Cat A"&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cat B = CALCULATE(&amp;nbsp;SUM(&amp;nbsp; 'Table'[Payment]&amp;nbsp; ),' Table'[Category] = "Cat B"&amp;nbsp;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cat C = CALCULATE(&amp;nbsp;SUM(&amp;nbsp; 'Table'[Payment]&amp;nbsp; ),' Table'[Category] = "Cat C"&amp;nbsp;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cat D = CALCULATE(&amp;nbsp;SUM(&amp;nbsp; 'Table'[Payment]&amp;nbsp; ),' Table'[Category] = "Cat D"&amp;nbsp;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Question 1: Is there a DAX formula that would eliminate the need to hard code the category name into the formula?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Question 2: I would like the formula to allow for dynamic addition of new categories.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jan 2020 02:54:28 GMT</pubDate>
    <dc:creator>bob57</dc:creator>
    <dc:date>2020-01-16T02:54:28Z</dc:date>
    <item>
      <title>Eliminate "hard coding".</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Eliminate-quot-hard-coding-quot/m-p/901475#M8246</link>
      <description>&lt;P&gt;Example table:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I am producing a pie chart to show the relationship of total payments for each category. I have four measures (one for each category).&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cat A = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE(&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;SUM(&amp;nbsp; 'Table'[Payment]&amp;nbsp; ),&lt;/SPAN&gt;&lt;SPAN&gt;' Table'[Category] = "Cat A"&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cat B = CALCULATE(&amp;nbsp;SUM(&amp;nbsp; 'Table'[Payment]&amp;nbsp; ),' Table'[Category] = "Cat B"&amp;nbsp;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cat C = CALCULATE(&amp;nbsp;SUM(&amp;nbsp; 'Table'[Payment]&amp;nbsp; ),' Table'[Category] = "Cat C"&amp;nbsp;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cat D = CALCULATE(&amp;nbsp;SUM(&amp;nbsp; 'Table'[Payment]&amp;nbsp; ),' Table'[Category] = "Cat D"&amp;nbsp;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Question 1: Is there a DAX formula that would eliminate the need to hard code the category name into the formula?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Question 2: I would like the formula to allow for dynamic addition of new categories.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 02:54:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Eliminate-quot-hard-coding-quot/m-p/901475#M8246</guid>
      <dc:creator>bob57</dc:creator>
      <dc:date>2020-01-16T02:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate "hard coding".</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Eliminate-quot-hard-coding-quot/m-p/901507#M8248</link>
      <description>&lt;P&gt;Can you share a sample file?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The basic solution would be to just have a simple sum formula:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Payment Amounts = 
CALCULATE(
    SUM(Table[Payment])
)&lt;/LI-CODE&gt;&lt;P&gt;Then use the category column in the legend section of the pie chart. That should give you the pie chat that you're looking for.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 03:29:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Eliminate-quot-hard-coding-quot/m-p/901507#M8248</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-01-16T03:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate "hard coding".</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Eliminate-quot-hard-coding-quot/m-p/901530#M8250</link>
      <description>&lt;P&gt;Thank you! That does solve my problem. I now understand that there is no need to worry about the addition of new categories. I'm new to DAX and Power BI so sometimes the simple things are not so simple.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 04:32:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Eliminate-quot-hard-coding-quot/m-p/901530#M8250</guid>
      <dc:creator>bob57</dc:creator>
      <dc:date>2020-01-16T04:32:17Z</dc:date>
    </item>
  </channel>
</rss>

