<?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 PYTD Function Issue in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/PYTD-Function-Issue/m-p/4056911#M161003</link>
    <description>&lt;P&gt;I need the PYTD function to give me just the total of sales for the same period last year as the current year period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the formula I am using for YTD:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;YTD =&lt;/SPAN&gt; &lt;SPAN&gt;TOTALYTD&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Combined Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Quota Credit]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;'Combined Table'&lt;/SPAN&gt;&lt;SPAN&gt;[QR Date]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;This is the formula for PYTD:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;QC PYTD =&lt;/SPAN&gt; &lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;TOTALYTD&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Combined Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Quota Credit]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;'Combined Table'&lt;/SPAN&gt;&lt;SPAN&gt;[QR Date]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Combined Table'&lt;/SPAN&gt;&lt;SPAN&gt;[QR Date]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;For some reason, for PYTD it is giving me the total sales for the year and not just the sales for last year that match up to the current time period in this year. Any suggestions would be great!&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 23 Jul 2024 15:49:53 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-07-23T15:49:53Z</dc:date>
    <item>
      <title>PYTD Function Issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/PYTD-Function-Issue/m-p/4056911#M161003</link>
      <description>&lt;P&gt;I need the PYTD function to give me just the total of sales for the same period last year as the current year period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the formula I am using for YTD:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;YTD =&lt;/SPAN&gt; &lt;SPAN&gt;TOTALYTD&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Combined Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Quota Credit]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;'Combined Table'&lt;/SPAN&gt;&lt;SPAN&gt;[QR Date]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;This is the formula for PYTD:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;QC PYTD =&lt;/SPAN&gt; &lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;TOTALYTD&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Combined Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Quota Credit]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;'Combined Table'&lt;/SPAN&gt;&lt;SPAN&gt;[QR Date]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Combined Table'&lt;/SPAN&gt;&lt;SPAN&gt;[QR Date]&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;For some reason, for PYTD it is giving me the total sales for the year and not just the sales for last year that match up to the current time period in this year. Any suggestions would be great!&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 Jul 2024 15:49:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/PYTD-Function-Issue/m-p/4056911#M161003</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-23T15:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: PYTD Function Issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/PYTD-Function-Issue/m-p/4057667#M161043</link>
      <description>&lt;P&gt;Hi,Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;1.First I have created the following table and the column names and data are the data you have given:&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;2. Below are the measure I've created for your needs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MEASURE = 
VAR cdate =
    CALCULATE (
        MAX ( 'Combined Table'[QR Date] ),
        FILTER (
            ALLSELECTED ( 'Combined Table' ),
            'Combined Table'[QR Date].[Year] = MAX ( 'Combined Table'[QR Date].[Year] )
        )
    )
RETURN
    CALCULATE (
        SUM ( 'Combined Table'[Quota Credit] ),
        FILTER (
            'Combined Table',
            'Combined Table'[QR Date].[Year]
                = YEAR ( cdate ) - 1
                &amp;amp;&amp;amp; 'Combined Table'[QR Date] &amp;lt;= EDATE ( cdate, -12 )
        )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;3.Here's my final result, which I hope meets your requirements.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&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 style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&lt;SPAN&gt;4.&lt;/SPAN&gt;&lt;SPAN&gt;Here are some links that may be helpful if you have similar questions&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-a-help-for-Last-Year-YTD-Data-by-Month-selection/td-p/4002075" target="_blank"&gt;&lt;SPAN&gt;Solved: Need a help for Last Year YTD Data by Month select... - Microsoft Fabric Community&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Please find the attached pbix relevant to the case.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Best Regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;Leroy Lu&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 12.0pt; color: black;"&gt;If this post &lt;SPAN&gt;helps&lt;/SPAN&gt;, then please consider Accept it &lt;SPAN&gt;as the solution &lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 02:47:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/PYTD-Function-Issue/m-p/4057667#M161043</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-24T02:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: PYTD Function Issue</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/PYTD-Function-Issue/m-p/4057771#M161052</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;TOTALYTD and SAMEPERIODLASTYEAR are time intelligence functions, to use them, you need a dedicated calendar table. Without the calendar table, try a measure like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;PYTD =
VAR _todaylastyear = EDATE(MAX('Combined Table'[QR Date]), -12)
VAR _result = 
CALCULATE(
    SUM('Combined Table'[Quota Credit]),
    FILTER(
        ALL('Combined Table'[QR Date]),
        'Combined Table'[QR Date])&amp;lt;_todaylastyear
            &amp;amp;&amp;amp;YEAR('Combined Table'[QR Date])) = YEAR(_todaylastyear)
    )
)
RETURN _result&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 Jul 2024 04:09:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/PYTD-Function-Issue/m-p/4057771#M161052</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2024-07-24T04:09:16Z</dc:date>
    </item>
  </channel>
</rss>

