<?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 Advice to optimize performance for a calculation of cumulative % in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4594999#M175964</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having a datamodel with a fact table called 'Ordre- og Fakturalinjer', which contains over 15 million rows of order and invoice lines. One of the columns is [Leverandør ID], which is connected to the dimension table called 'Leverandør', which contain 16.000 unique suppliers.&lt;BR /&gt;&lt;BR /&gt;I have created these measures to calculate a Akkumuleret Forbrug % (Cumulative %):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Forbrug = SUM ( 'Ordre- og Fakturalinjer'[Forbrug (DKK)] )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Forbrug Rank = 

IF (
    ISINSCOPE ( 'Leverandør'[Leverandør] ),
    RANKX(
        ALLSELECTED ( 'Leverandør'[Leverandør] ),
        [Total Forbrug])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Forbrug GT% = 
DIVIDE ( 
    [Total Forbrug],
    [Forbrug ialt],
    0
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Akkumuleret Forbrug % = 
 divide (
     [Akkumuleret Forbrug],
     [Forbrug ialt],
     0
 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I use following columns in a table visual:&lt;BR /&gt;'Leverandør'[Leverandør]&lt;BR /&gt;[Total Forbrug]&lt;BR /&gt;[Total Forbrug Rank]&lt;/P&gt;&lt;P&gt;[Total Forbrug GT%]&lt;BR /&gt;[Akkumuleret Forbrug %]&lt;BR /&gt;&lt;BR /&gt;When I trace the performance of the table in DAX Studio it takes almost 167.000 ms. The problem lies in the measure [Akkumuleret Forbrug %].&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Any advice to optimize the existing measure or do it in another way to get faster load time for the visual table.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Morten&lt;/P&gt;</description>
    <pubDate>Tue, 04 Mar 2025 13:40:53 GMT</pubDate>
    <dc:creator>RegionH</dc:creator>
    <dc:date>2025-03-04T13:40:53Z</dc:date>
    <item>
      <title>Advice to optimize performance for a calculation of cumulative %</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4594999#M175964</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having a datamodel with a fact table called 'Ordre- og Fakturalinjer', which contains over 15 million rows of order and invoice lines. One of the columns is [Leverandør ID], which is connected to the dimension table called 'Leverandør', which contain 16.000 unique suppliers.&lt;BR /&gt;&lt;BR /&gt;I have created these measures to calculate a Akkumuleret Forbrug % (Cumulative %):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Forbrug = SUM ( 'Ordre- og Fakturalinjer'[Forbrug (DKK)] )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Forbrug Rank = 

IF (
    ISINSCOPE ( 'Leverandør'[Leverandør] ),
    RANKX(
        ALLSELECTED ( 'Leverandør'[Leverandør] ),
        [Total Forbrug])
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total Forbrug GT% = 
DIVIDE ( 
    [Total Forbrug],
    [Forbrug ialt],
    0
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Akkumuleret Forbrug % = 
 divide (
     [Akkumuleret Forbrug],
     [Forbrug ialt],
     0
 )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I use following columns in a table visual:&lt;BR /&gt;'Leverandør'[Leverandør]&lt;BR /&gt;[Total Forbrug]&lt;BR /&gt;[Total Forbrug Rank]&lt;/P&gt;&lt;P&gt;[Total Forbrug GT%]&lt;BR /&gt;[Akkumuleret Forbrug %]&lt;BR /&gt;&lt;BR /&gt;When I trace the performance of the table in DAX Studio it takes almost 167.000 ms. The problem lies in the measure [Akkumuleret Forbrug %].&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Any advice to optimize the existing measure or do it in another way to get faster load time for the visual table.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Morten&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 13:40:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4594999#M175964</guid>
      <dc:creator>RegionH</dc:creator>
      <dc:date>2025-03-04T13:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Advice to optimize performance for a calculation of cumulative %</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4595022#M175965</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="584463" data-lia-user-login="RegionH" class="lia-mention lia-mention-user"&gt;RegionH&lt;/a&gt;&amp;nbsp;Try using&lt;/P&gt;
&lt;P&gt;DAX&lt;BR /&gt;Total Forbrug = SUM ( 'Ordre- og Fakturalinjer'[Forbrug (DKK)] )&lt;/P&gt;
&lt;P&gt;Total Forbrug Rank = &lt;BR /&gt;VAR CurrentSupplier = SELECTEDVALUE('Leverandør'[Leverandør])&lt;BR /&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;ISINSCOPE ( 'Leverandør'[Leverandør] ),&lt;BR /&gt;RANKX(&lt;BR /&gt;ALLSELECTED ( 'Leverandør'[Leverandør] ),&lt;BR /&gt;[Total Forbrug],&lt;BR /&gt;,&lt;BR /&gt;DESC,&lt;BR /&gt;DENSE&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;Total Forbrug GT% = &lt;BR /&gt;DIVIDE ( &lt;BR /&gt;[Total Forbrug],&lt;BR /&gt;[Forbrug ialt],&lt;BR /&gt;0&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;Akkumuleret Forbrug % = &lt;BR /&gt;VAR CurrentSupplier = SELECTEDVALUE('Leverandør'[Leverandør])&lt;BR /&gt;VAR CumulativeForbrug = &lt;BR /&gt;CALCULATE (&lt;BR /&gt;[Total Forbrug],&lt;BR /&gt;FILTER (&lt;BR /&gt;ALLSELECTED('Leverandør'[Leverandør]),&lt;BR /&gt;[Total Forbrug Rank] &amp;lt;= RANKX(ALLSELECTED('Leverandør'[Leverandør]), [Total Forbrug])&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;DIVIDE (&lt;BR /&gt;CumulativeForbrug,&lt;BR /&gt;[Forbrug ialt],&lt;BR /&gt;0&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 13:59:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4595022#M175965</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2025-03-04T13:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Advice to optimize performance for a calculation of cumulative %</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4595060#M175968</link>
      <description>&lt;P&gt;Thank you for your respons. It is definetely very fast, but unfortunately it is not showing the correct cummulative percentage. It shows 1 on each row. I would expect on row one the percentage is 11,2% and the percentage on row two is 19,1%.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;BR /&gt;Morten&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 14:19:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4595060#M175968</guid>
      <dc:creator>RegionH</dc:creator>
      <dc:date>2025-03-04T14:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Advice to optimize performance for a calculation of cumulative %</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4595180#M175971</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="584463" data-lia-user-login="RegionH" class="lia-mention lia-mention-user"&gt;RegionH&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dax&lt;BR /&gt;Total Forbrug = SUM ( 'Ordre- og Fakturalinjer'[Forbrug (DKK)] )&lt;/P&gt;
&lt;P&gt;Total Forbrug Rank =&lt;BR /&gt;VAR CurrentSupplier = SELECTEDVALUE('Leverandør'[Leverandør])&lt;BR /&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;ISINSCOPE ( 'Leverandør'[Leverandør] ),&lt;BR /&gt;RANKX(&lt;BR /&gt;ALLSELECTED ( 'Leverandør'[Leverandør] ),&lt;BR /&gt;[Total Forbrug],&lt;BR /&gt;,&lt;BR /&gt;DESC,&lt;BR /&gt;DENSE&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;Total Forbrug GT% =&lt;BR /&gt;DIVIDE (&lt;BR /&gt;[Total Forbrug],&lt;BR /&gt;[Forbrug ialt],&lt;BR /&gt;0&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;Akkumuleret Forbrug % =&lt;BR /&gt;VAR CurrentSupplier = SELECTEDVALUE('Leverandør'[Leverandør])&lt;BR /&gt;VAR CumulativeForbrug =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUMX(&lt;BR /&gt;FILTER(&lt;BR /&gt;ALLSELECTED('Leverandør'),&lt;BR /&gt;'Leverandør'[Leverandør] &amp;lt;= CurrentSupplier&lt;BR /&gt;),&lt;BR /&gt;[Total Forbrug]&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;DIVIDE (&lt;BR /&gt;CumulativeForbrug,&lt;BR /&gt;[Forbrug ialt],&lt;BR /&gt;0&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 14:54:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4595180#M175971</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2025-03-04T14:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Advice to optimize performance for a calculation of cumulative %</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4595238#M175975</link>
      <description>&lt;P&gt;The measure is definitely faster with 90.000 ms. But it's showing the incorrect cumulative percentages,&amp;nbsp;because you use SELECTEDVALUE() to compare suppliers in your filter. This approach does not work correctly in an accumulated measure because you are trying to compare text values ​​directly across multiple rows, and SELECTEDVALUE() returns only one value.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 15:32:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4595238#M175975</guid>
      <dc:creator>RegionH</dc:creator>
      <dc:date>2025-03-04T15:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Advice to optimize performance for a calculation of cumulative %</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4596538#M176009</link>
      <description>&lt;P&gt;I ended up with this DAX code, which is executed in 4.522 ms, which is acceptable for me.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Running Total % = 

VAR _SpendTotal =
    CALCULATE ( [Total Forbrug], ALLSELECTED ( 'Leverandør'[Leverandør] ) )

VAR _FilteredTable =
    CALCULATETABLE (
        ALLSELECTED ( 'Leverandør'[Leverandør] ),
        'Ordre- og Fakturalinjer'[Forbrug (DKK)] &amp;gt; 0
    )

VAR _NewTable =
    ADDCOLUMNS (
        _FilteredTable,
        "@spendtotal", [Total Forbrug]
    )
VAR _CumulateTable =
    ADDCOLUMNS (
        _NewTable,
        "@cumulatesum",
            SUMX (
                FILTER ( _NewTable, [@spendtotal] &amp;gt;= EARLIER ( [@spendtotal] ) ),
                [@spendtotal]
            ),
        "@total", _SpendTotal
    )
VAR _Result =
    MAXX (
        FILTER (
            ADDCOLUMNS ( _CumulateTable, "@result", DIVIDE ( [@cumulatesum], [@total] ) ),
            'Leverandør'[Leverandør] = MAX ( 'Leverandør'[Leverandør] )
        ),
        [@result]
    )
RETURN
    IF (
        HASONEVALUE ( 'Leverandør'[Leverandør] ),
        _Result,
        BLANK()
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 05 Mar 2025 11:48:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Advice-to-optimize-performance-for-a-calculation-of-cumulative/m-p/4596538#M176009</guid>
      <dc:creator>RegionH</dc:creator>
      <dc:date>2025-03-05T11:48:02Z</dc:date>
    </item>
  </channel>
</rss>

