<?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: Dax optimisation in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-optimisation/m-p/3653340#M141535</link>
    <description>&lt;P&gt;Certainly, optimizing DAX expressions is crucial for improving performance. In your case, I see that you're using a variable (CurrentDate) to find the latest date for the selected date range and then using it in the filter context. Here are a few suggestions for optimizing your DAX expression:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Avoid Using Variables if Not Necessary:&lt;/STRONG&gt; Instead of using a variable to store the CurrentDate, you can directly use the MAX function in your filter conditions. This might help to simplify the DAX expression.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;OpenCases =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('Fact Bridge Period'),&lt;BR /&gt;'Fact Bridge Period'[MeasureKey] = 56,&lt;BR /&gt;'Fact Bridge Period'[ReportingStartDateKey] = MAX('Fact Bridge Period'[ReportingStartDateKey])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Filtering on MeasureKey:&lt;/STRONG&gt;&lt;SPAN&gt; If the condition &lt;/SPAN&gt;'Fact Bridge Period'[MeasureKey] = 56&lt;SPAN&gt; is common across multiple measures, you might consider creating a measure that filters based on this condition, and then reusing it in your other measures. This can help in better code organization and potential performance improvement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MeasureKeyFilter = 'Fact Bridge Period'[MeasureKey] = 56&lt;/P&gt;&lt;P&gt;OpenCases =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('Fact Bridge Period'),&lt;BR /&gt;MeasureKeyFilter,&lt;BR /&gt;'Fact Bridge Period'[ReportingStartDateKey] = MAX('Fact Bridge Period'[ReportingStartDateKey])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Use of Relationships:&lt;/STRONG&gt; Ensure that your relationships between tables are properly defined. Incorrect relationships can impact the performance of your DAX expressions.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Consider using FILTER and VALUES:&lt;/STRONG&gt; Depending on your data model, you might experiment with using the FILTER and VALUES functions to improve performance.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OpenCases =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS(FILTER('Fact Bridge Period', 'Fact Bridge Period'[MeasureKey] = 56)),&lt;BR /&gt;'Fact Bridge Period'[ReportingStartDateKey] = MAX('Fact Bridge Period'[ReportingStartDateKey])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Remember, the optimization depends on the specific characteristics of your data model and the query patterns in your report. It's a good practice to test the performance impact of different optimizations and choose the one that works best for your scenario.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2024 07:29:16 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2024-01-23T07:29:16Z</dc:date>
    <item>
      <title>Dax optimisation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-optimisation/m-p/3651207#M141451</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a DAX expression that runs fine, until I try to construct the drill through table with multiple columns from different dimension.&amp;nbsp; I found out that MAX I can bring 7 column, more than 7 column result with constatnt loading time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The model is star schema with Superfact (Bridge table). Measure needs to bring the valaue based on the visual.&amp;nbsp;&lt;BR /&gt;E.g. if the visual shows Month granularity, like Jan 2023, Feb 2023, April 2023 etc = vlaue of this Month; if visual shows Q1 2023, Q2 2023, Q3 2023, Q4 2023 = then values&amp;nbsp; for the latest Month in the Quarter March 2023, June 2023, Sep 2023, Dec 2023; if visual selected only year, eg, 2022, 2023, 2024 = then value for the latest Month in the Year, Dec 22, Dec 23, Dec 24&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Current DAX expresion&lt;/STRONG&gt;&lt;BR /&gt;OpenCases =&lt;BR /&gt;VAR CurrentDate = MAX('Fact Bridge Period'[ReportingStartDateKey]) --finding latest date for selected date range on the visual--&lt;BR /&gt;VAR OpenCases = CALCULATE(COUNTROWS('Fact Bridge Period'),&lt;BR /&gt;'Fact Bridge Period'[MeasureKey]=56,&lt;BR /&gt;'Fact Bridge Period'[ReportingStartDateKey]=CurrentDate --bring the value that matches Max date for selected visual period--&lt;BR /&gt;)&lt;BR /&gt;RETURN OpenCases&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I wonder if there is a way to optimise this DAX expresion.&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 08:57:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-optimisation/m-p/3651207#M141451</guid>
      <dc:creator>XeniaLi</dc:creator>
      <dc:date>2024-01-22T08:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dax optimisation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-optimisation/m-p/3653340#M141535</link>
      <description>&lt;P&gt;Certainly, optimizing DAX expressions is crucial for improving performance. In your case, I see that you're using a variable (CurrentDate) to find the latest date for the selected date range and then using it in the filter context. Here are a few suggestions for optimizing your DAX expression:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Avoid Using Variables if Not Necessary:&lt;/STRONG&gt; Instead of using a variable to store the CurrentDate, you can directly use the MAX function in your filter conditions. This might help to simplify the DAX expression.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;OpenCases =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('Fact Bridge Period'),&lt;BR /&gt;'Fact Bridge Period'[MeasureKey] = 56,&lt;BR /&gt;'Fact Bridge Period'[ReportingStartDateKey] = MAX('Fact Bridge Period'[ReportingStartDateKey])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Filtering on MeasureKey:&lt;/STRONG&gt;&lt;SPAN&gt; If the condition &lt;/SPAN&gt;'Fact Bridge Period'[MeasureKey] = 56&lt;SPAN&gt; is common across multiple measures, you might consider creating a measure that filters based on this condition, and then reusing it in your other measures. This can help in better code organization and potential performance improvement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MeasureKeyFilter = 'Fact Bridge Period'[MeasureKey] = 56&lt;/P&gt;&lt;P&gt;OpenCases =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('Fact Bridge Period'),&lt;BR /&gt;MeasureKeyFilter,&lt;BR /&gt;'Fact Bridge Period'[ReportingStartDateKey] = MAX('Fact Bridge Period'[ReportingStartDateKey])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Use of Relationships:&lt;/STRONG&gt; Ensure that your relationships between tables are properly defined. Incorrect relationships can impact the performance of your DAX expressions.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Consider using FILTER and VALUES:&lt;/STRONG&gt; Depending on your data model, you might experiment with using the FILTER and VALUES functions to improve performance.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OpenCases =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS(FILTER('Fact Bridge Period', 'Fact Bridge Period'[MeasureKey] = 56)),&lt;BR /&gt;'Fact Bridge Period'[ReportingStartDateKey] = MAX('Fact Bridge Period'[ReportingStartDateKey])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Remember, the optimization depends on the specific characteristics of your data model and the query patterns in your report. It's a good practice to test the performance impact of different optimizations and choose the one that works best for your scenario.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 07:29:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-optimisation/m-p/3653340#M141535</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-01-23T07:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Dax optimisation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-optimisation/m-p/3653580#M141549</link>
      <description>&lt;P&gt;Hi thanks for your answer.&lt;BR /&gt;&lt;BR /&gt;I think this poart of code might not work:&lt;BR /&gt;'Fact Bridge Period'[ReportingStartDateKey] = MAX('Fact Bridge Period'[ReportingStartDateKey])&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;The reason I used variables coz CALCULATE&amp;nbsp; do not support comparing a column to a an aggregate value.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I will test if wrapping MAX part in FILTER function helps.&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;Thanks for the idea.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 09:09:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-optimisation/m-p/3653580#M141549</guid>
      <dc:creator>XeniaLi</dc:creator>
      <dc:date>2024-01-23T09:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dax optimisation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-optimisation/m-p/3653743#M141554</link>
      <description>&lt;P&gt;You're correct, and I appreciate your clarification. In DAX, you can't directly compare a column to an aggregate value outside of a context transition. The FILTER function can indeed be useful in such scenarios. If you encounter issues, another common approach is to use the CALCULATETABLE function with VALUES to get a single-column table containing distinct values of 'Fact Bridge Period'[ReportingStartDateKey] for the current context.&lt;/P&gt;&lt;P&gt;Here's an example using CALCULATETABLE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OpenCases =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('Fact Bridge Period'),&lt;BR /&gt;'Fact Bridge Period'[MeasureKey] = 56,&lt;BR /&gt;'Fact Bridge Period'[ReportingStartDateKey] IN VALUES('Fact Bridge Period'[ReportingStartDateKey])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This expression leverages VALUES to obtain a table of distinct ReportingStartDateKey values in the current context and then uses the IN operator to filter based on that list. This should address the issue of comparing a column to an aggregate value. Please test this approach in your specific context to ensure it meets your performance and functionality requirements.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 10:21:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dax-optimisation/m-p/3653743#M141554</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-01-23T10:21:42Z</dc:date>
    </item>
  </channel>
</rss>

