<?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: Referencing to Measure or rather working with variables? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Referencing-to-Measure-or-rather-working-with-variables/m-p/1971099#M43314</link>
    <description>&lt;P&gt;As usual, IT DEPENDS. If you have defined meaningful business measures, then you should reuse them as much as possible because code duplication is the first step to hell. You should catch measure values into variables most of the time and give them good names. Remembering at that that a measure's value stored in a variable will never change. This is helpful when used correctly. Also, using variables is very beneficial when debugging code. The rule I go by is: If your expression is short, you don't need to catch everyching into variables because the short code (with well named measures) speaks for itself. If your expression is complex, use variables with good names.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jul 2021 18:14:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-07-21T18:14:41Z</dc:date>
    <item>
      <title>Referencing to Measure or rather working with variables?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Referencing-to-Measure-or-rather-working-with-variables/m-p/1970619#M43275</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Usually I create a lot of measures and even use nested measures as well. But now I am wondering if thats a best practice approach. Should I use variables rather than nesting or referencing to other measures?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;An example for calculating a simple ratio.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Approach 1 with nestes measures:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Measure 1 = SUM( value 1 )&lt;/LI&gt;&lt;LI&gt;Measure 2 = SUM( value 2 )&lt;/LI&gt;&lt;LI&gt;Measure 3 = DIVIDE( Measure 2, Measure 1 )&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Approach 2 with variables:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Measure 1:&lt;BR /&gt;var 1 = SUM( value 1 )&amp;nbsp;&lt;BR /&gt;var 2 = SUM( value 2 )&lt;BR /&gt;RETURN&lt;BR /&gt;DIVIDE( 2, 1 )&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;What do you think?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 13:38:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Referencing-to-Measure-or-rather-working-with-variables/m-p/1970619#M43275</guid>
      <dc:creator>raymondpocher</dc:creator>
      <dc:date>2021-07-21T13:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing to Measure or rather working with variables?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Referencing-to-Measure-or-rather-working-with-variables/m-p/1970649#M43276</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="310774" data-lia-user-login="raymondpocher" class="lia-mention lia-mention-user"&gt;raymondpocher&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For me &lt;STRONG&gt;Approach 2&lt;/STRONG&gt; works better. There are few reasons for using variables rather than multiple measures:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Using variables make my DAX calculation simpler and easy to understand.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;If I have everything in a single DAX expression, it is easy to maintain, specially in the cases where the DAX is not working as expected then debugging is easier. You need to check one expression for debugging rather than checking multiple measures used to create this calculation.&lt;/LI&gt;
&lt;LI&gt;Based on my previous experience with writing DAX, I have seen that use of variables improves performance as well. You can check this for example on the two visuals displaying calculation output using Approach 1 and Approach 2.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;This is my view, but I am sure others will have more to add to this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Pragati&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 13:49:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Referencing-to-Measure-or-rather-working-with-variables/m-p/1970649#M43276</guid>
      <dc:creator>Pragati11</dc:creator>
      <dc:date>2021-07-21T13:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing to Measure or rather working with variables?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Referencing-to-Measure-or-rather-working-with-variables/m-p/1971099#M43314</link>
      <description>&lt;P&gt;As usual, IT DEPENDS. If you have defined meaningful business measures, then you should reuse them as much as possible because code duplication is the first step to hell. You should catch measure values into variables most of the time and give them good names. Remembering at that that a measure's value stored in a variable will never change. This is helpful when used correctly. Also, using variables is very beneficial when debugging code. The rule I go by is: If your expression is short, you don't need to catch everyching into variables because the short code (with well named measures) speaks for itself. If your expression is complex, use variables with good names.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 18:14:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Referencing-to-Measure-or-rather-working-with-variables/m-p/1971099#M43314</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-21T18:14:41Z</dc:date>
    </item>
  </channel>
</rss>

