<?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 SWITCH with SAMEPERIODLASTYEAR does not work well in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-with-SAMEPERIODLASTYEAR-does-not-work-well/m-p/3061577#M105821</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I am writing a DAX like this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR sv = SELECTEDVALUE(‘select type’[type])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR test = SWITCH(sv, “Off”, SUM(prod[abs_off]), “On”, SUM(prod[abs_onl]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR previos_val = CALCULATE (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;test,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;SAMEPERIODLASTYEAR(‘Date’[Date]) )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RETURN DIVIDE (test, previos_val) * 100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;in the result it always returns 100, although if I insert a value from switch results into calculate(), all works well. How to fix this issue?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 04 Feb 2023 16:30:53 GMT</pubDate>
    <dc:creator>IliaS</dc:creator>
    <dc:date>2023-02-04T16:30:53Z</dc:date>
    <item>
      <title>SWITCH with SAMEPERIODLASTYEAR does not work well</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-with-SAMEPERIODLASTYEAR-does-not-work-well/m-p/3061577#M105821</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am writing a DAX like this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR sv = SELECTEDVALUE(‘select type’[type])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR test = SWITCH(sv, “Off”, SUM(prod[abs_off]), “On”, SUM(prod[abs_onl]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR previos_val = CALCULATE (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;test,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;SAMEPERIODLASTYEAR(‘Date’[Date]) )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RETURN DIVIDE (test, previos_val) * 100&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;in the result it always returns 100, although if I insert a value from switch results into calculate(), all works well. How to fix this issue?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2023 16:30:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-with-SAMEPERIODLASTYEAR-does-not-work-well/m-p/3061577#M105821</guid>
      <dc:creator>IliaS</dc:creator>
      <dc:date>2023-02-04T16:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: SWITCH with SAMEPERIODLASTYEAR does not work well</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-with-SAMEPERIODLASTYEAR-does-not-work-well/m-p/3061599#M105822</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="509691" data-lia-user-login="IliaS" class="lia-mention lia-mention-user"&gt;IliaS&lt;/a&gt;&amp;nbsp;Variables (VAR) are not dynamic or well, variable. Confusing yes. Variables are static once calculated so you can't recalculate them using CALCULATE. If you separate into 2 measures then yes. Also, I recommend avoiding TI functions.&amp;nbsp;You may find this helpful - &lt;A href="https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2023 16:59:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SWITCH-with-SAMEPERIODLASTYEAR-does-not-work-well/m-p/3061599#M105822</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-02-04T16:59:22Z</dc:date>
    </item>
  </channel>
</rss>

