<?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: Balance of previous year in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Balance-of-previous-year/m-p/1299536#M22475</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="245823" data-lia-user-login="JPScotland" class="lia-mention lia-mention-user"&gt;JPScotland&lt;/a&gt; , same weekday is 364 days behind.&lt;/P&gt;
&lt;P&gt;Week Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-364,Days))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using week rank you can find last year same week (52 week behind)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)&lt;/P&gt;
&lt;P&gt;This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))&lt;BR /&gt;Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))&lt;BR /&gt;Last year Week= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;refer my blogs&lt;/P&gt;
&lt;P&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3&lt;/A&gt;&lt;BR /&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;To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer : &lt;BR /&gt;&lt;A href="https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions" target="_blank"&gt;https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions&lt;/A&gt; &lt;BR /&gt;&lt;A href="https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi" target="_blank"&gt;https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;See if my webinar on Time Intelligence can help: &lt;A href="https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184" target="_blank"&gt;https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Appreciate your Kudos.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Aug 2020 03:31:35 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2020-08-17T03:31:35Z</dc:date>
    <item>
      <title>Balance of previous year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Balance-of-previous-year/m-p/1298067#M22423</link>
      <description>&lt;P&gt;I have a table (&lt;EM&gt;PeriodBal&lt;/EM&gt;) with weekly account balances from the start of the previous financial year to the present date (1. 5 years worth of data).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;PerioidBal&lt;/EM&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Period End Date&lt;/TD&gt;&lt;TD&gt;V Period Balance&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1001&lt;/TD&gt;&lt;TD&gt;01/04/2018&lt;/TD&gt;&lt;TD&gt;550&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1001&lt;/TD&gt;&lt;TD&gt;08/04/2018&lt;/TD&gt;&lt;TD&gt;562&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1002&lt;/TD&gt;&lt;TD&gt;01/04/2018&lt;/TD&gt;&lt;TD&gt;998&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1002&lt;/TD&gt;&lt;TD&gt;08/04/2018&lt;/TD&gt;&lt;TD&gt;305&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;and so on right up until today&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&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;I also have a Dates table that shows the finacial week (Start of April).&amp;nbsp; The tables are joined by Period End Date = Date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Dates&lt;/EM&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Year&lt;/TD&gt;&lt;TD&gt;Month&lt;/TD&gt;&lt;TD&gt;Week Number&lt;/TD&gt;&lt;TD&gt;Financial Week Number&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;09/08/2020&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;August&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;TD&gt;19&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10/08/2020&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;August&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;TD&gt;19&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/08/2020&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;August&lt;/TD&gt;&lt;TD&gt;31&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a measure that gives me the balance of the previous year.&amp;nbsp; I cant use SAMEPERIODLASTYEAR as the balances of each week fall on a different date i.e. Week 19 Ends on the 19/08 in 2020 but 11/08 in 2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure (&lt;EM&gt;Most Recent Period Date&lt;/EM&gt;) that gives me the most recent Period End Date = 09/08/2020.&amp;nbsp; Using this I hope to pull the financial week from this year to look up last year.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Last Years Arrears Balance =&lt;BR /&gt;VAR &lt;EM&gt;WeekNo&lt;/EM&gt; = LOOKUPVALUE(Dates[Financial Week Number],Dates[Date],[&lt;EM&gt;Most Recent Period Date&lt;/EM&gt;])&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;CALCULATE (&lt;BR /&gt;SUM(PeriodBal[V Period Balance]),&lt;BR /&gt;FILTER (Dates,Dates[Financial Week] = &lt;EM&gt;WeekNo&lt;/EM&gt;&lt;BR /&gt;&amp;amp;&amp;amp; Dates[Year] = YEAR (TODAY() -1&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think the problem is the Lookup is bringing back multiple values so I had a read up on FIRSTNONBLANK but I cant seem to get it to work across tables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also feel I am over complicating the whole thing as I can show the data easily in a filtered table.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be very much apprecaited.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;JP&lt;/P&gt;</description>
      <pubDate>Sat, 15 Aug 2020 14:15:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Balance-of-previous-year/m-p/1298067#M22423</guid>
      <dc:creator>JPScotland</dc:creator>
      <dc:date>2020-08-15T14:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Balance of previous year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Balance-of-previous-year/m-p/1298194#M22427</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="245823" data-lia-user-login="JPScotland" class="lia-mention lia-mention-user"&gt;JPScotland&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See if this blog helps&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;pbix attached to the blog&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Harsh Nathani&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Appreciate with a Kudos!! (Click the Thumbs Up Button)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Aug 2020 15:50:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Balance-of-previous-year/m-p/1298194#M22427</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-15T15:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Balance of previous year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Balance-of-previous-year/m-p/1299536#M22475</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="245823" data-lia-user-login="JPScotland" class="lia-mention lia-mention-user"&gt;JPScotland&lt;/a&gt; , same weekday is 364 days behind.&lt;/P&gt;
&lt;P&gt;Week Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-364,Days))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using week rank you can find last year same week (52 week behind)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)&lt;/P&gt;
&lt;P&gt;This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))&lt;BR /&gt;Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))&lt;BR /&gt;Last year Week= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;refer my blogs&lt;/P&gt;
&lt;P&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3&lt;/A&gt;&lt;BR /&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;To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer : &lt;BR /&gt;&lt;A href="https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions" target="_blank"&gt;https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions&lt;/A&gt; &lt;BR /&gt;&lt;A href="https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi" target="_blank"&gt;https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/" target="_blank"&gt;https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;See if my webinar on Time Intelligence can help: &lt;A href="https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184" target="_blank"&gt;https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Appreciate your Kudos.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 03:31:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Balance-of-previous-year/m-p/1299536#M22475</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-08-17T03:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Balance of previous year</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Balance-of-previous-year/m-p/1300197#M22498</link>
      <description>&lt;P&gt;Thank you both for replying.&amp;nbsp;&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&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="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp; - I thought about that way and it does work but I am not sure how accurate it will be when dealing with leap years etc?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found this video which is similar to what I want to do (&lt;A href="https://www.youtube.com/watch?v=g_3eLaKgeEQ" target="_blank" rel="noopener"&gt;https://www.youtube.com/watch?v=g_3eLaKgeEQ&lt;/A&gt;).&amp;nbsp; This issue was then that I didnt have FiscalYears in my calendar so I found this helpful site (&lt;A href="https://goodly.co.in/financial-year-calculation-excel-and-power-bi/" target="_blank" rel="noopener"&gt;https://goodly.co.in/financial-year-calculation-excel-and-power-bi/&lt;/A&gt;).&amp;nbsp; The Fiscal Calendar is huge so I only setup a few years instead of the entire table.&amp;nbsp; I then linked this to my Date table.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="lia-message-author-with-avatar"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Balance 1 Year Ago = 
    VAR FiscalWeek = SELECTEDVALUE(FiscalCalendar[Fiscal Week])
    VAR FiscalYear = SELECTEDVALUE(FiscalCalendar[Fiscal Year])

RETURN
    CALCULATE (
            SUM (PeriodBal[V Period Balance]),
            FILTER(ALL(FiscalCalendar),
                    FiscalCalendar[Fiscal Week] = FiscalWeek
                    &amp;amp;&amp;amp; FiscalCalendar[Fiscal Year] = FiscalYear -1)
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this is really only good in a table as far as I can see as it gives you the result for each row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;JP&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 08:28:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Balance-of-previous-year/m-p/1300197#M22498</guid>
      <dc:creator>JPScotland</dc:creator>
      <dc:date>2020-08-17T08:28:40Z</dc:date>
    </item>
  </channel>
</rss>

