<?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: How to write a dax to Get cumulative sum till 6th row and after 6th row rolling 6 months sum ? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204647#M51841</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you need a DAX Calculated column? And the logic is about June and differentiate years?&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cum_NS = 
VAR CurMonth =  MONTH(Sheet3[Date])
RETURN
IF(CurMonth&amp;lt;7, SUMX(FILTER(Sheet3,Sheet3[Year]=EARLIER(Sheet3[Year])&amp;amp;&amp;amp;MONTH(Sheet3[Date])&amp;lt;=CurMonth),Sheet3[NS]),
SUMX(FILTER(Sheet3,Sheet3[Year]=EARLIER(Sheet3[Year])&amp;amp;&amp;amp;MONTH(Sheet3[Date])&amp;lt;=CurMonth&amp;amp;&amp;amp;MONTH(Sheet3[Date])&amp;gt;=CurMonth-6),Sheet3[NS]))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Nov 2021 00:44:23 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-11-24T00:44:23Z</dc:date>
    <item>
      <title>How to write a dax to Get cumulative sum till 6th row and after 6th row rolling 6 months sum ?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204257#M51820</link>
      <description>&lt;P&gt;HI Team,&lt;/P&gt;&lt;P&gt;I've requirement to calculate two different conditions:&lt;/P&gt;&lt;P&gt;1. To calculate cummulative sum till 6th row&lt;/P&gt;&lt;P&gt;2. To calculate Rollling 6 months sum (After 6 th row)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reference Link for PBI:&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;U&gt;&lt;STRONG&gt;&lt;A href="https://1drv.ms/u/s!Au-aOkl1BoHuhytgh_iqEh6UG4WA?e=IwUWDN" target="_blank"&gt;https://1drv.ms/u/s!Au-aOkl1BoHuhytgh_iqEh6UG4WA?e=IwUWDN&lt;/A&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Formula:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;&lt;img /&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reference Link for PBI:&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;U&gt;&lt;STRONG&gt;&lt;A href="https://1drv.ms/u/s!Au-aOkl1BoHuhytgh_iqEh6UG4WA?e=IwUWDN" target="_blank"&gt;https://1drv.ms/u/s!Au-aOkl1BoHuhytgh_iqEh6UG4WA?e=IwUWDN&lt;/A&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you need anything&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks In Advance&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 18:50:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204257#M51820</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-11-23T18:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a dax to Get cumulative sum till 6th row and after 6th row rolling 6 months sum ?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204647#M51841</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you need a DAX Calculated column? And the logic is about June and differentiate years?&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cum_NS = 
VAR CurMonth =  MONTH(Sheet3[Date])
RETURN
IF(CurMonth&amp;lt;7, SUMX(FILTER(Sheet3,Sheet3[Year]=EARLIER(Sheet3[Year])&amp;amp;&amp;amp;MONTH(Sheet3[Date])&amp;lt;=CurMonth),Sheet3[NS]),
SUMX(FILTER(Sheet3,Sheet3[Year]=EARLIER(Sheet3[Year])&amp;amp;&amp;amp;MONTH(Sheet3[Date])&amp;lt;=CurMonth&amp;amp;&amp;amp;MONTH(Sheet3[Date])&amp;gt;=CurMonth-6),Sheet3[NS]))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 00:44:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204647#M51841</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-11-24T00:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a dax to Get cumulative sum till 6th row and after 6th row rolling 6 months sum ?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204934#M51849</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I suggest having a Dim-Date table and using the time intelligence function in DAX to create a measure.&lt;/P&gt;
&lt;P&gt;However, if you do not have a Dim-Date table, please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;Create a calculated column in the table, that is the Month Number CC, and then create measures like below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;EM&gt;&lt;STRONG&gt;NS total: =&lt;/STRONG&gt; &lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;SUM( Sheet3[NS] )&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;&lt;STRONG&gt;NS 6 months rolling: = &lt;/STRONG&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;VAR currentyearmonth_sortID =&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;MAX ( Sheet3[Year] ) * 12&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt; + MAX ( Sheet3[Month Number CC] )&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;VAR newtable =&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;ADDCOLUMNS (&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;ALL ( Sheet3 ),&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;"@NSTotal", [NS total:],&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;"@sortID",&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;CALCULATE ( MAX ( Sheet3[Year] ) * 12 + MAX ( Sheet3[Month Number CC] ) )&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt; )&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;VAR filternewtable =&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;FILTER (&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;newtable,&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;[@sortID] &amp;gt;= currentyearmonth_sortID - 5&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt; &amp;amp;&amp;amp; [@sortID] &amp;lt;= currentyearmonth_sortID&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt; )&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;RETURN&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;SUMX ( filternewtable, [@NSTotal] )&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 24 Nov 2021 04:19:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204934#M51849</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2021-11-24T04:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a dax to Get cumulative sum till 6th row and after 6th row rolling 6 months sum ?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204937#M51851</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the response. Yes we need calculated column and need some changes in formula&lt;/P&gt;&lt;P&gt;In the formula need changes.&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;&lt;STRONG&gt;We don't need to&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;differentiate years&lt;/STRONG&gt; means starting from the 7th row in table same logic shiould be applied to till the last .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example:&amp;nbsp; in the current formula, from every every year stating month it will be recalculated .&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Expected :&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;It shouldn't be recalculated and from 7th row it should be&amp;nbsp; be rolling 6 months sum irrespective of the year.&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;2. &lt;STRONG&gt;Logic is not related on June month&lt;/STRONG&gt; and it should be related on the rownumber&amp;nbsp;&lt;/P&gt;&lt;P&gt;means if the data start from jun 2018 to 2021 nov then the first 6&amp;nbsp; rows should be cummulative after that it should be last 6 months rolling sum.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me&amp;nbsp; know if you need any details&lt;/P&gt;&lt;P&gt;Thanks In Advance&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 04:22:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204937#M51851</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-11-24T04:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a dax to Get cumulative sum till 6th row and after 6th row rolling 6 months sum ?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204995#M51856</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So does the table sort by date? We can add the Row number based on date?&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CurRow = COUNTROWS(FILTER(Sheet3,Sheet3[Date]&amp;lt;=EARLIER(Sheet3[Date])))


Cum_NS = 
VAR CurR=Sheet3[CurRow]
RETURN
IF([CurRow]&amp;lt;7, SUMX(FILTER(Sheet3,Sheet3[CurRow]&amp;lt;=CurR),Sheet3[NS]),
SUMX(FILTER(Sheet3,Sheet3[CurRow]&amp;gt;=CurR-6&amp;amp;&amp;amp;Sheet3[CurRow]&amp;lt;=CurR),Sheet3[NS]))&lt;/LI-CODE&gt;
&lt;P&gt;Otherwise you need to add Index column as Row number via Power Query&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Please also consider the size and the suggestion from&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 05:24:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-write-a-dax-to-Get-cumulative-sum-till-6th-row-and-after/m-p/2204995#M51856</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-11-24T05:24:26Z</dc:date>
    </item>
  </channel>
</rss>

