<?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: Cumulative measure with condition and specific window size (unbounded preceding to current_row-1) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-measure-with-condition-and-specific-window-size/m-p/1748593#M36375</link>
    <description>&lt;P&gt;Not clear. Please refer to this guide:&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/How-to-Get-Your-Question-Answered-Quickly/td-p/1626726" target="_blank"&gt;How to Get Your Question Answered Quickly (powerbi.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Mar 2021 15:46:30 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-03-26T15:46:30Z</dc:date>
    <item>
      <title>Cumulative measure with condition and specific window size (unbounded preceding to current_row-1)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-measure-with-condition-and-specific-window-size/m-p/1746663#M36335</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some project data as follows:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I have made a star schema from the attributes that I need for processing such as asset type and precinct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the financial analysis, I have selected some of the columns that are required and unpivoted the Fys data to appear in the rows (not columns) as shown below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fy is the year part of Fys and cashflow is the value of that column.&lt;/P&gt;&lt;P&gt;Fys stands for the financial year and the Grand Total is the sum of all Fys.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I need to calculate commitment. I have added a column in the above example to show how it is calculated. The logic is as follows:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;Problem:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;For the first year, it is equal to the sum of all the Fys (which we can get from Grand total rather than summing up all Fys). For any other year (i.e. second, third,...), commitment is equal to the Grand total - (sum of the cash flow of all the &lt;STRONG&gt;previous&lt;/STRONG&gt; years). Therefore, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;For the first year it is qual to Grand Total i.e. 1500.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;For the second year, it is Grand total - Cash flow first year (i.e. Fy first year), i.e. 1500-100=1400. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;For the third year, it is Grand Total - (Fy first year +Fy second year), i.e. 1500- (100+200)=1200.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;and so on&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since these projects may have different start dates and end dates and they may happen in different years, I have removed those Fys which are null and calculated the rank for the remaining based on the Fys . For example, for the above example, all the Fys from 2025 to 2050 are null, so I have removed them as they are not shown in the unpivoted table and they are ranked based on the value of Fys in ascending order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My rank formula:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Rank = CALCULATE(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;COUNTROWS('DPO Portfolio_FY'),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;FILTER(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ALL('DPO Portfolio_FY'),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;'DPO Portfolio_FY'[Id] = EARLIER('DPO Portfolio_FY'[Id]) &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;'DPO Portfolio_FY'[FY_Start] &amp;lt; EARLIER('DPO Portfolio_FY'[FY_Start])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)+1 &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Happy to use Power Query or DAX or any other possible way&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Numerical Example:&lt;/DIV&gt;&lt;/DIV&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;PK&lt;/TD&gt;&lt;TD&gt;Asset type&lt;/TD&gt;&lt;TD&gt;Precinct&lt;/TD&gt;&lt;TD&gt;Rank&lt;/TD&gt;&lt;TD&gt;FY&lt;/TD&gt;&lt;TD&gt;Cashflow&lt;/TD&gt;&lt;TD&gt;Actual Commitment&lt;/TD&gt;&lt;TD&gt;Grand Total&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt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gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 18:32:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-measure-with-condition-and-specific-window-size/m-p/1746663#M36335</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-27T18:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative measure with condition and specific window size (unbounded preceding to current_row-1)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-measure-with-condition-and-specific-window-size/m-p/1748593#M36375</link>
      <description>&lt;P&gt;Not clear. Please refer to this guide:&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/How-to-Get-Your-Question-Answered-Quickly/td-p/1626726" target="_blank"&gt;How to Get Your Question Answered Quickly (powerbi.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 15:46:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-measure-with-condition-and-specific-window-size/m-p/1748593#M36375</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-26T15:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative measure with condition and specific window size (unbounded preceding to current_row-1)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-measure-with-condition-and-specific-window-size/m-p/1748863#M36389</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;, thanks for the comment, I have revised it to make it easier to understand and hopefully clear this time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Mar 2021 17:23:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-measure-with-condition-and-specific-window-size/m-p/1748863#M36389</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-28T17:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative measure with condition and specific window size (unbounded preceding to current_row-1)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-measure-with-condition-and-specific-window-size/m-p/1750271#M36468</link>
      <description>&lt;P&gt;I have to use a calculated column as it is a row by row calc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This &lt;A href="http://dinesql.blogspot.com/2017/05/power-bi-cumulative-running-totals-measure-or-calculated-column.html" target="_self"&gt;link&lt;/A&gt; helped me a lot&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Comm_calc1 =CALCULATE (sum ('DPO Portfolio_FY'[Cash Flow]),Filter(&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ALLEXCEPT(&lt;/FONT&gt;&lt;/STRONG&gt;'DPO Portfolio_FY','DPO Portfolio_FY'[Id]),'DPO Portfolio_FY'[Rank]&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&amp;lt;EARLIER&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;('DPO Portfolio_FY'[Rank])))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;and then&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Commitment =&amp;nbsp; if('DPO Portfolio_FY'[Rank]==1,'DPO Portfolio_FY'[Grand Total],'DPO Portfolio_FY'[Grand Total]-'DPO Portfolio_FY'[Comm_calc1])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 28 Mar 2021 20:30:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Cumulative-measure-with-condition-and-specific-window-size/m-p/1750271#M36468</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-28T20:30:07Z</dc:date>
    </item>
  </channel>
</rss>

