<?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 function in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-function/m-p/3803074#M148696</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have some trouble with a switch function that operates very slow and I think it's due to an Allselected in some measures but don't know how to fix it, so would be so gelreatful for some help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have several data tables and have created measures for a number of vales I want to show in a matrix for month, ytd etc with some formatting for each measures how they shall be viewed. For the ones I have direct data to there's no issue, but for some I have created a measure based on two different measures, for example FTE absence divided by FTE to get a dynanic percentage. If I have this measure directly in the matrix via a switch function no values are displayed, but I have read about using allselected in a calculate function and then it works, but this is taking so long time when I change month for example. I have a spec dimension table that I'm using for the switch and matrix and have added all spec names in this table, including these that has no direct data but where I get the numbers thru two measures.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&lt;/P&gt;&lt;P&gt;s there another way of doing this smoothly and more efficient and hope the above makes sense? I also have this issue in an income statement where I use Allselected in my functions for the Ebit etc where I use that function for a dimension table for the rows from the income statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;</description>
    <pubDate>Mon, 01 Apr 2024 21:11:19 GMT</pubDate>
    <dc:creator>Rocon</dc:creator>
    <dc:date>2024-04-01T21:11:19Z</dc:date>
    <item>
      <title>Switch function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-function/m-p/3803074#M148696</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have some trouble with a switch function that operates very slow and I think it's due to an Allselected in some measures but don't know how to fix it, so would be so gelreatful for some help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have several data tables and have created measures for a number of vales I want to show in a matrix for month, ytd etc with some formatting for each measures how they shall be viewed. For the ones I have direct data to there's no issue, but for some I have created a measure based on two different measures, for example FTE absence divided by FTE to get a dynanic percentage. If I have this measure directly in the matrix via a switch function no values are displayed, but I have read about using allselected in a calculate function and then it works, but this is taking so long time when I change month for example. I have a spec dimension table that I'm using for the switch and matrix and have added all spec names in this table, including these that has no direct data but where I get the numbers thru two measures.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&lt;/P&gt;&lt;P&gt;s there another way of doing this smoothly and more efficient and hope the above makes sense? I also have this issue in an income statement where I use Allselected in my functions for the Ebit etc where I use that function for a dimension table for the rows from the income statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 21:11:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-function/m-p/3803074#M148696</guid>
      <dc:creator>Rocon</dc:creator>
      <dc:date>2024-04-01T21:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Switch function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-function/m-p/3803290#M148700</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="635369" data-lia-user-login="Rocon" class="lia-mention lia-mention-user"&gt;Rocon&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the Allselected function in the Calculate function does affect performance, especially when working with large data sets or complex calculations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is because Allselected retains all filters except those on the rows and columns of the table that uses it, which can lead to a lot of recalculations when the context changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/allselected-function-dax" target="_blank"&gt;ALLSELECTED function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try the following methods to improve performance:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Simplify the calculation logic as much as possible and make sure that only what is necessary is calculated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If MEASURE is complex, consider using variables to store intermediate results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Using variables in your DAX formulas can help you write more complex and efficient calculations. Variables can improve performance, reliability, readability, and reduce complexity.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/best-practices/dax-variables" target="_blank"&gt;Use variables to improve your DAX formulas - DAX | Microsoft Learn&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If performance issues are indeed related to the use of Allsselected, please consider whether you need to use it in all cases.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Use the performance analyzer in Power BI Desktop to determine which visual objects or metrics take the longest to load.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-performance-analyzer" target="_blank"&gt;Use Performance Analyzer to examine report element performance in Power BI Desktop - Power BI | Microsoft Learn&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Nono Chen&lt;/P&gt;
&lt;P&gt;If this &lt;STRONG&gt;&lt;EM&gt;post&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;helps, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 01:20:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-function/m-p/3803290#M148700</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-02T01:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Switch function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-function/m-p/3811194#M149053</link>
      <description>&lt;P&gt;Thank you so much for your answer Nuno!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The thing is that the calculations is not that advanced but since I have YTD, YTD FC, YTD LY, Month etc it seems like it takes a lot of the performance. I have a measure like this where I use ALLSELECTED but when I remove the ALLSELECTED from the formula, no value is being displayed:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Absence (Short term) % =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;DIVIDE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[Absence (Short term) Total FTE]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; (&lt;/SPAN&gt;&lt;SPAN&gt;[Active Direct FTE (Exc Temps)]&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;[Active Indirect FTE (Exc Temps)]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ALLSELECTED&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Dim_Attributes&lt;/SPAN&gt;&lt;SPAN&gt;[ID]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; ).&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;I have these measures that formats the current measure in the period type I want:&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Month AC =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;CurrentValue&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;[*Switch_value]&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;Selection_VersionType&lt;/SPAN&gt;&lt;SPAN&gt;[AC_FC]&lt;/SPAN&gt;&lt;SPAN&gt;=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PAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Everything is connected to a Dimension table for the specifications, but I can't find a good solution for this or if the formatting and ALLSELECTED function is something I have to work with to get the numbers ok. For the above, I don't have Absence % in any data and only get this from the calculation.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 04 Apr 2024 14:17:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-function/m-p/3811194#M149053</guid>
      <dc:creator>Rocon</dc:creator>
      <dc:date>2024-04-04T14:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Switch function</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-function/m-p/3829952#M149743</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="635369" data-lia-user-login="Rocon" class="lia-mention lia-mention-user"&gt;Rocon&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Can you provide detailed sample pbix file and the results you expect.So that I can help you better. Please remove any sensitive data in advance.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Nono Chen&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 07:53:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-function/m-p/3829952#M149743</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-11T07:53:06Z</dc:date>
    </item>
  </channel>
</rss>

