<?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: Previous N week data in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1144183#M17185</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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check this blog.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Harsh Nathani&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jun 2020 11:10:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-06-05T11:10:37Z</dc:date>
    <item>
      <title>Previous N week data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1144136#M17183</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table that captures registrations for events and this table has 2 date fields - &lt;STRONG&gt;RegistrationDate&lt;/STRONG&gt; and &lt;STRONG&gt;EventStartDate.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to calculate the &lt;STRONG&gt;cumulative&lt;/STRONG&gt; No. of registrations for each event from the previous 52 weeks until the event starts (illustrated below).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ESD = Event Start Date&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;EventName &lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ESD-52week&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ESD-51week&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ESD-50week&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;...&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ESD-2week&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ESD-1week&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ESD-0week&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Event1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;44&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Event2&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;TD&gt;42&lt;/TD&gt;&lt;TD&gt;54&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Event3&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;TD&gt;47&lt;/TD&gt;&lt;TD&gt;66&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The last numbers (44, 54, 66) are the total registrations for the respective events.&lt;/P&gt;&lt;P&gt;Calculation on the registrations need to be on RegistrationDate and reaches its max at EventStartDate.&lt;/P&gt;&lt;P&gt;A tabular representation would work fine for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas on how this can be achieved, please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 10:57:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1144136#M17183</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-05T10:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Previous N week data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1144183#M17185</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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please check this blog.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Harsh Nathani&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 11:10:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1144183#M17185</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-05T11:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Previous N week data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1144196#M17187</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;The criticality of my requirement is that we have 2 separate date fields and the calculation is based on both.&lt;/P&gt;&lt;P&gt;No. of registrations are being calculated on the RegistrationDate, whereas the offset needs to be calculated on the EventStartDate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 11:22:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1144196#M17187</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-05T11:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Previous N week data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1145001#M17240</link>
      <description>&lt;P&gt;So looking back 52 weeks but not before the registration date, or will there not be any registratios anyway before the registration date?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 20:08:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1145001#M17240</guid>
      <dc:creator>stevedep</dc:creator>
      <dc:date>2020-06-05T20:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Previous N week data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1145162#M17248</link>
      <description>&lt;P&gt;The simplest way to do this would be just add a calculated column to your table with this formula&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RegistrationWeek = DATEDIFF(Table[EventStartDate], Table[RegistrationDate], WEEK)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That will give you # of weeks before the event (-1,-42, etc.).&amp;nbsp; You can then make a matrix with Event on the rows and the new column on the Columns, and use a running total measure like this&lt;BR /&gt;&lt;BR /&gt;Cumulative Registrations =&lt;BR /&gt;VAR __thisweek =&lt;BR /&gt;SELECTEDVALUE ( Table[RegistrationWeek] )&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE (&lt;BR /&gt;COUNTROWS ( Table ),&lt;BR /&gt;ALL ( Table[RegistrationWeek] ),&lt;BR /&gt;Table[RegistrationWeek] &amp;lt;= __thisweek&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this works for you, please mark it as the solution.&amp;nbsp; Kudos are appreciated too.&amp;nbsp; Please let me know if not.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pat&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jun 2020 01:09:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1145162#M17248</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-06-06T01:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Previous N week data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1145887#M17291</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226208" data-lia-user-login="mahoneypat" class="lia-mention lia-mention-user"&gt;mahoneypat&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is excellent Pat... Thanks a ton.&lt;/P&gt;&lt;P&gt;Your solution is just about right. I can modify the rest as per the requirement.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jun 2020 13:53:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1145887#M17291</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-07T13:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Previous N week data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1153111#M17568</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="226208" data-lia-user-login="mahoneypat" class="lia-mention lia-mention-user"&gt;mahoneypat&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As per your suggestion, this is what I could achieve.&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;There are a couple more things that I would like to know :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 1&lt;/STRONG&gt; - How can I populate the empty cells with the same previous value? (For eg - the highlighted part should contain 150 for -3, -2, -1 and 0 weeks)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 2&lt;/STRONG&gt; - If I select only events that has gaps, even the header (RegistrationWeek) skips the columns that has no data. How can I keep this static to always show 0 to -52 even if there is no data? (this is related to Question 1 as there is no data to show in that column)&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 13:19:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1153111#M17568</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-11T13:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Previous N week data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1154045#M17611</link>
      <description>&lt;P&gt;The reason you are seeing blanks is that there are no rows for that week, so there is not a RegistrationWeek value to go in the first part with SELECTEDVALUE().&amp;nbsp; To get around that there are two approaches that could work.&amp;nbsp; I recommend the second one:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Add blank rows in the query editor to fill in the missing dates/weeks (e.g., make a full list of dates/weeks, convert to table, and then merge your data into it for each customer)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Make a disconnected table of regisration week numbers (e.g., with GENERATESERIES(-42,1,1) or something like that and use that in your columns.&amp;nbsp; Then modify the measure expression to get the SELECTEDVALUE() of that column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this works for you, please mark it as the solution.&amp;nbsp; Kudos are appreciated too.&amp;nbsp; Please let me know if not.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pat&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 22:58:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1154045#M17611</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-06-11T22:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Previous N week data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1155654#M17651</link>
      <description>&lt;P&gt;Went by the second approach and that helped... Thank you!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 12:10:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-N-week-data/m-p/1155654#M17651</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-12T12:10:15Z</dc:date>
    </item>
  </channel>
</rss>

