<?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: Running totals are taking too long and the visual exceeds time limit in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3375154#M127089</link>
    <description>&lt;P&gt;They are all pretty much the same&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Last Contributions = 

VAR mostRecentMonth = LASTDATE(Assets[process_period_date])
VAR prevMonth = PREVIOUSMONTH(mostRecentMonth)
var result = CALCULATE(
                SUM(Assets[amount]),
                Assets[tran_code] = 101 ||
                Assets[tran_code] = 102 ||
                Assets[tran_code] = 103 ||
                Assets[tran_code] = 109 ||
                Assets[tran_code] = 133,
                Assets[process_period_date] = mostRecentMonth
)
RETURN result&lt;/LI-CODE&gt;&lt;P&gt;2.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Last Distribution = 
VAR mostRecentMonth = LASTDATE(Assets[process_period_date])
VAR distributions = CALCULATE(
                        SUM(Assets[amount]),
                        Assets[tran_code] = 501 ||
                        Assets[tran_code] = 502 ||
                        Assets[tran_code] = 503 ||
                        Assets[tran_code] = 504 ||
                        Assets[tran_code] = 509
)
RETURN distributions&lt;/LI-CODE&gt;&lt;P&gt;3.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Last Earnings = 
VAR mostRecentMonth = LASTDATE(Assets[process_period_date])

VAR earnings = CALCULATE(
                    SUM(Assets[amount]),
                    Assets[tran_code] = 301 ||
                    Assets[tran_code] = 302 ||
                    Assets[tran_code] = 305 ||
                    Assets[tran_code] = 309 ||
                    Assets[tran_code] = 333,
                    Assets[process_period_date] = mostRecentMonth
)
RETURN earnings&lt;/LI-CODE&gt;&lt;P&gt;4.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Last Expenses = 
VAR mostRecentMonth = LASTDATE(Assets[process_period_date])

VAR lastExpense = CALCULATE(
                    SUM(Assets[amount]),
                    Assets[tran_code] = 401 ||
                    Assets[tran_code] = 402 ||
                    Assets[tran_code] = 403 ||
                    Assets[tran_code] = 404 ||
                    Assets[tran_code] = 405 ||
                    Assets[tran_code] = 406 ||
                    Assets[tran_code] = 407 ||
                    Assets[tran_code] = 408 ||
                    Assets[tran_code] = 409 ||
                    Assets[tran_code] = 410 ||
                    Assets[tran_code] = 411 ||
                    Assets[tran_code] = 433,
                    Assets[process_period_date] = mostRecentMonth
)
RETURN lastExpense&lt;/LI-CODE&gt;&lt;P&gt;5.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Last Transfer Total = 
VAR mostRecentMonth = LASTDATE(Assets[process_period_date])
VAR transferIn = CALCULATE(
                    SUM(Assets[amount]),
                    Assets[tran_code] = 201 ||
                    Assets[tran_code] = 209,
                    Assets[process_period_date] = mostRecentMonth
)
VAR transferOut = CALCULATE(
                    SUM(Assets[amount]),
                    Assets[tran_code] = 601 ||
                    Assets[tran_code] = 609,
                    Assets[process_period_date] = mostRecentMonth
)

return transferIn + transferOut&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Aug 2023 22:46:08 GMT</pubDate>
    <dc:creator>CarlSagan</dc:creator>
    <dc:date>2023-08-10T22:46:08Z</dc:date>
    <item>
      <title>Running totals are taking too long and the visual exceeds time limit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3374640#M127079</link>
      <description>&lt;P&gt;I have a visual that uses five measures which compute running totals based on dates. I was wondering if anyone could give me tips on optimizing the performance my code, I'm basically doing the same thing for each measure. Choose a specific date as the last date to sum up all previous totals under.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Beginning Balance = 
VAR lastD = LASTDATE(Assets[process_period_date])
var lastM = MONTH(lastD)
VAR prevM = PREVIOUSMONTH(lastD)

var begBal = CALCULATE(
                SUM(Assets[amount]),
                Assets[process_period_date] &amp;lt;= prevM
)

RETURN begBal&lt;/LI-CODE&gt;&lt;P&gt;Then I there is the final measure that sums up the previous five measure, I'm not sure if it is computing all of the measures again?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Last Ending Balance = 
    [Beginning Balance] + [Last Earnings] + [Last Expenses] + [Last Distribution] + [Last Contributions] + [Last Transfer Total]&lt;/LI-CODE&gt;&lt;P&gt;Am I supposed to be reusing variables so I don't need to compute them again?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 16:09:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3374640#M127079</guid>
      <dc:creator>CarlSagan</dc:creator>
      <dc:date>2023-08-10T16:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Running totals are taking too long and the visual exceeds time limit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3374830#M127082</link>
      <description>&lt;P&gt;What are the other measure definitions? I have an optimization idea but would need to see the other ones.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another thing you can do is run each measure by itself, record times, and see which one is taking the longest. Then work on optimizing that one particular measure.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this post was helpful, please kudos or accept the answer as a solution.&lt;BR /&gt;~ Anthony Genovese&lt;BR /&gt;Need more PBI help? PM me for affordable, dedicated training or consultant recomendations!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 17:59:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3374830#M127082</guid>
      <dc:creator>AnthonyGenovese</dc:creator>
      <dc:date>2023-08-10T17:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Running totals are taking too long and the visual exceeds time limit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3375154#M127089</link>
      <description>&lt;P&gt;They are all pretty much the same&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Last Contributions = 

VAR mostRecentMonth = LASTDATE(Assets[process_period_date])
VAR prevMonth = PREVIOUSMONTH(mostRecentMonth)
var result = CALCULATE(
                SUM(Assets[amount]),
                Assets[tran_code] = 101 ||
                Assets[tran_code] = 102 ||
                Assets[tran_code] = 103 ||
                Assets[tran_code] = 109 ||
                Assets[tran_code] = 133,
                Assets[process_period_date] = mostRecentMonth
)
RETURN result&lt;/LI-CODE&gt;&lt;P&gt;2.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Last Distribution = 
VAR mostRecentMonth = LASTDATE(Assets[process_period_date])
VAR distributions = CALCULATE(
                        SUM(Assets[amount]),
                        Assets[tran_code] = 501 ||
                        Assets[tran_code] = 502 ||
                        Assets[tran_code] = 503 ||
                        Assets[tran_code] = 504 ||
                        Assets[tran_code] = 509
)
RETURN distributions&lt;/LI-CODE&gt;&lt;P&gt;3.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Last Earnings = 
VAR mostRecentMonth = LASTDATE(Assets[process_period_date])

VAR earnings = CALCULATE(
                    SUM(Assets[amount]),
                    Assets[tran_code] = 301 ||
                    Assets[tran_code] = 302 ||
                    Assets[tran_code] = 305 ||
                    Assets[tran_code] = 309 ||
                    Assets[tran_code] = 333,
                    Assets[process_period_date] = mostRecentMonth
)
RETURN earnings&lt;/LI-CODE&gt;&lt;P&gt;4.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Last Expenses = 
VAR mostRecentMonth = LASTDATE(Assets[process_period_date])

VAR lastExpense = CALCULATE(
                    SUM(Assets[amount]),
                    Assets[tran_code] = 401 ||
                    Assets[tran_code] = 402 ||
                    Assets[tran_code] = 403 ||
                    Assets[tran_code] = 404 ||
                    Assets[tran_code] = 405 ||
                    Assets[tran_code] = 406 ||
                    Assets[tran_code] = 407 ||
                    Assets[tran_code] = 408 ||
                    Assets[tran_code] = 409 ||
                    Assets[tran_code] = 410 ||
                    Assets[tran_code] = 411 ||
                    Assets[tran_code] = 433,
                    Assets[process_period_date] = mostRecentMonth
)
RETURN lastExpense&lt;/LI-CODE&gt;&lt;P&gt;5.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Last Transfer Total = 
VAR mostRecentMonth = LASTDATE(Assets[process_period_date])
VAR transferIn = CALCULATE(
                    SUM(Assets[amount]),
                    Assets[tran_code] = 201 ||
                    Assets[tran_code] = 209,
                    Assets[process_period_date] = mostRecentMonth
)
VAR transferOut = CALCULATE(
                    SUM(Assets[amount]),
                    Assets[tran_code] = 601 ||
                    Assets[tran_code] = 609,
                    Assets[process_period_date] = mostRecentMonth
)

return transferIn + transferOut&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 22:46:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3375154#M127089</guid>
      <dc:creator>CarlSagan</dc:creator>
      <dc:date>2023-08-10T22:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Running totals are taking too long and the visual exceeds time limit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3376589#M127156</link>
      <description>&lt;P&gt;Why not just do this? You should be able to put all your codes in an IN statement, or a long OR block. That will reduce some overhead and potential blocking. Also, if you have a dimension for asset transaction codes and have a realtionship to the asset table, you could create an attribute such as [Tran Code Type] "Transfer IN", "Transfer Out" etc and then just filter on those.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;CALCULATE(
                    SUM(Assets[amount]),
                    Assets[tran_code] = { 401,402,ALL YOUR CODES}
                    Assets[process_period_date] = mostRecentMonth
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, is there a filter on Assets[Process_period_date]? Is the measure displaying data correctly? Because I would think you would need to remove the filter before doing the = mostRecentMonth&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this post was helpful, please kudos or accept the answer as a solution.&lt;BR /&gt;~ Anthony Genovese&lt;BR /&gt;Need more PBI help? PM me for affordable, dedicated training or consultant recomendations!&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2023 15:16:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3376589#M127156</guid>
      <dc:creator>AnthonyGenovese</dc:creator>
      <dc:date>2023-08-11T15:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: Running totals are taking too long and the visual exceeds time limit</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3376737#M127164</link>
      <description>&lt;P&gt;I don't think using the IN operator is going to make that much of a difference since the IN is translated into the multiple OR expression anyway. So I re-created the data model in a different project and am doing the same exact calculations and I have it working.&lt;BR /&gt;&lt;BR /&gt;The more I've been playing around with it, it seems to be that the bottle neck is actually bringing in related columns from different tables. I think, how can I tell using the optimizer?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2023 17:28:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Running-totals-are-taking-too-long-and-the-visual-exceeds-time/m-p/3376737#M127164</guid>
      <dc:creator>CarlSagan</dc:creator>
      <dc:date>2023-08-11T17:28:08Z</dc:date>
    </item>
  </channel>
</rss>

