<?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: SWITCH and IF always doing eager evaluation in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4135020#M164248</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="729029" data-lia-user-login="trattnh" class="lia-mention lia-mention-user"&gt;trattnh&lt;/a&gt;&amp;nbsp;- I'm sorry, I dont know of a way you can re-write this to see if you can force a strict evaluation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you thought about using a field parameter to switch between the measures instead?&lt;/P&gt;</description>
    <pubDate>Thu, 05 Sep 2024 08:27:17 GMT</pubDate>
    <dc:creator>mark_endicott</dc:creator>
    <dc:date>2024-09-05T08:27:17Z</dc:date>
    <item>
      <title>SWITCH and IF always doing eager evaluation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4133599#M164188</link>
      <description>&lt;P&gt;&lt;SPAN&gt;From what I read online switch does eager evaluation and IF does lazy evaluation.&lt;BR /&gt;I have defined both options. Both take the same amount of time (I analyzed this in dax studio).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the server timings it only actually evaluates a single measure but if I comment out measure2 and measure3&amp;nbsp; and leave only measure1 which is the&amp;nbsp;&amp;nbsp;selected_measure_name - it reduces the speed by 2/3. If I comment ony one, the speed is reduced by 1/3 - so it seems to be evaluating nevertheless.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, if I return some hardcoded string instead of "measure_value" nothing is evaluated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am confused by this behavior of the query.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Either it is doing eager evaluation or it isn't... &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR selected_measure_name = LOOKUPVALUE(my_table[measure_name], my_table[field_name], SELECTEDVALUE(my_table[field_name]))&lt;BR /&gt;VAR measure_value =&amp;nbsp;SWITCH (TRUE(),&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;selected_measure_name = "measure1", [measure1],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;selected_measure_name = "measure2", [measure2],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;selected_measure_name = "measure3", [measure3]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BLANK()&lt;BR /&gt;)&lt;BR /&gt;return measure_value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR selected_measure_name = LOOKUPVALUE(my_table[measure_name], my_table[field_name], SELECTEDVALUE(my_table[field_name]))&lt;BR /&gt;return&amp;nbsp;IF(selected_measure_name = "measure1", [measure1],&lt;BR /&gt;&amp;nbsp; &amp;nbsp;IF(selected_measure_name = "measure2", [measure2],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IF(selected_measure_name = "measure3", [measure3],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BLANK())))&lt;BR /&gt;return measure_value&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 14:31:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4133599#M164188</guid>
      <dc:creator>trattnh</dc:creator>
      <dc:date>2024-09-04T14:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: SWITCH and IF always doing eager evaluation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4133685#M164190</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="729029" data-lia-user-login="trattnh" class="lia-mention lia-mention-user"&gt;trattnh&lt;/a&gt;&amp;nbsp;- I'm not sure if this a query or if you are providing information. But yes SWITCH and IF will likely use&amp;nbsp;the same query plan if the Vertipaq engine evaluation decides EAGER is the best option. You can force IF to do an EAGER evalution with IF. EAGER&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Incidentally, you probably dont need the LOOKUPVALUE in your selected_measure_name variable. If there is one "measure" per "field_name" you can just use MAX(&amp;nbsp;&lt;SPAN&gt;my_table[measure_name] ) because however you are selecting&amp;nbsp;field_name the MAX will always grab the appropriate measure_name from the row of this table. This version should be slightly quicker in DAX Studio.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can find more information here:&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/understanding-eager-vs-strict-evaluation-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/understanding-eager-vs-strict-evaluation-in-dax/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 15:04:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4133685#M164190</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2024-09-04T15:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: SWITCH and IF always doing eager evaluation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4134683#M164231</link>
      <description>&lt;P&gt;This is a query. My issue is that assuming that measures 1, 2, 3 all take the same time to execute, the SWITCH or IFstatement should take the same time to execute regardless of how many options I have in them.&amp;nbsp; In reality, the time increases for every option I add. If I add options for measures 4, 5, 6 the statement will take twice the amount of time than if I only had measures 1, 2, 3, even though only a single measure should be evaluated according to the value of&amp;nbsp;&lt;SPAN&gt;selected_measure_name.&lt;BR /&gt;In effect, I am trying to write a measure that "gets as input" another measure by name and then returns the value of that measure - this is in order to prevent the need to duplicate complex measures where the only difference is the name of an internal measure it is calling&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 05:43:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4134683#M164231</guid>
      <dc:creator>trattnh</dc:creator>
      <dc:date>2024-09-05T05:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: SWITCH and IF always doing eager evaluation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4135020#M164248</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="729029" data-lia-user-login="trattnh" class="lia-mention lia-mention-user"&gt;trattnh&lt;/a&gt;&amp;nbsp;- I'm sorry, I dont know of a way you can re-write this to see if you can force a strict evaluation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you thought about using a field parameter to switch between the measures instead?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 08:27:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4135020#M164248</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2024-09-05T08:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: SWITCH and IF always doing eager evaluation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4135265#M164259</link>
      <description>&lt;P&gt;Actually, I need to do something similar to displaying a table visual which has two columns - measure name, measure value.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 11:06:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-and-IF-always-doing-eager-evaluation/m-p/4135265#M164259</guid>
      <dc:creator>trattnh</dc:creator>
      <dc:date>2024-09-05T11:06:06Z</dc:date>
    </item>
  </channel>
</rss>

