<?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: Measure for YoY YTD in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4185148#M166189</link>
    <description>&lt;PRE&gt;VAR _previouseyear_rev = CALCULATE([Total Revenue],'400_Revenue'[Year] = _currentyear - 1)&lt;/PRE&gt;&lt;P&gt;Did you try using SAMEPERIODLASTYEAR ?&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2024 17:57:38 GMT</pubDate>
    <dc:creator>SachinNandanwar</dc:creator>
    <dc:date>2024-09-27T17:57:38Z</dc:date>
    <item>
      <title>Measure for YoY YTD</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4185125#M166188</link>
      <description>&lt;P&gt;Hello DAX Gods,&lt;/P&gt;&lt;P&gt;I have this table in one of my PowerBI reports that shows YoY % Revenue growth. For the most part, this looks right with the execption of the current year because we are only in September. How can I show the YoY % to only calculate vs YTD of previous year?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I'm using the following DAX formula for the Rev YoY Growth %:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rev YoY Growth % = 
VAR _currentyear_rev = [Total Revenue]
VAR _currentyear = MAX('400_Revenue'[Year])
VAR _previouseyear_rev = CALCULATE([Total Revenue],'400_Revenue'[Year] = _currentyear - 1)
VAR _YoYGrowth = 
    DIVIDE(
            _currentyear_rev - _previouseyear_rev, _previouseyear_rev
    )
RETURN
    IF(
        HASONEVALUE('400_Revenue'[Year]),
        IF(
            NOT ISBLANK(_currentyear_rev) &amp;amp;&amp;amp; NOT ISBLANK(_previouseyear_rev),
            _YoYGrowth
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 17:34:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4185125#M166188</guid>
      <dc:creator>egrospe17</dc:creator>
      <dc:date>2024-09-27T17:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: Measure for YoY YTD</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4185148#M166189</link>
      <description>&lt;PRE&gt;VAR _previouseyear_rev = CALCULATE([Total Revenue],'400_Revenue'[Year] = _currentyear - 1)&lt;/PRE&gt;&lt;P&gt;Did you try using SAMEPERIODLASTYEAR ?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 17:57:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4185148#M166189</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-09-27T17:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Measure for YoY YTD</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4185331#M166193</link>
      <description>&lt;P&gt;Hi SachinNandanwar,&lt;/P&gt;&lt;P&gt;How would I incorporate SAMEPERIODLASTYEAR to my existing formula?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried following this thread but it didn't produced the result I needed. the YoY% just returned as null when I put it on a table.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-and-YoY-for-Measure/m-p/3536287#M135886" target="_blank"&gt;https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-and-YoY-for-Measure/m-p/3536287#M135886&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 19:12:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4185331#M166193</guid>
      <dc:creator>egrospe17</dc:creator>
      <dc:date>2024-09-27T19:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Measure for YoY YTD</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4185528#M166198</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="308176" data-lia-user-login="egrospe17" class="lia-mention lia-mention-user"&gt;egrospe17&lt;/a&gt;&amp;nbsp;: So basically you need to compare Jan-Sep 2023 with Jan-Sep 2024 for calculating YoY%, right ?&lt;BR /&gt;&lt;BR /&gt;For that you can use a combination of&amp;nbsp;DATESYTD and SAMEPERIODLASTYEAR.&lt;BR /&gt;&lt;BR /&gt;Something like&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE([Total Revenue], DATESYTD(SAMEPERIODLASTYEAR('400_Revenue'[Date])))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 20:48:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4185528#M166198</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-09-27T20:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Measure for YoY YTD</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4216482#M167120</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="308176" data-lia-user-login="egrospe17" class="lia-mention lia-mention-user"&gt;egrospe17&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Based on your needs, I have created the following table.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First you can use the following Measure to get the total revenue every year.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Total Revenue = 
VAR _year = [Year]
RETURN
SUMX(FILTER(ALL('Table'),'Table'[Year]=_year),'Table'[Revenue])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then&amp;nbsp;you can use the following Measure to get the result you want:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;YoY % Revenue growth = 
VAR _year = [Year]
VAR _sameperiodtotal = CALCULATE ( [Total Revenue], DATESYTD ( SAMEPERIODLASTYEAR ( 'Table'[Date] ) ) )
VAR _maxmonth = MAXX (
            FILTER ( ALL ( 'Table' ), 'Table'[Year] = _year ),
            MONTH ( 'Table'[Date] )
        )
RETURN
    IF (
         _maxmonth&amp;lt; 12,
        DIVIDE (
            SUMX ( FILTER ( ALL ( 'Table' ), 'Table'[Year] = _year ), 'Table'[Revenue] ),
            SUMX (
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[Year] = _year - 1
                        &amp;amp;&amp;amp; MONTH ( 'Table'[Date] )
                            &amp;lt;= _maxmonth
                ),
                'Table'[Revenue]
            )
        )-1,
        DIVIDE (
            [Total Revenue]-_sameperiodtotal,
            _sameperiodtotal
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&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;&amp;nbsp;&lt;/P&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jayleny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 02:43:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-for-YoY-YTD/m-p/4216482#M167120</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-04T02:43:31Z</dc:date>
    </item>
  </channel>
</rss>

