<?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: Prior Year measure, with an additional field to consider in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-measure-with-an-additional-field-to-consider/m-p/2644610#M77780</link>
    <description>&lt;P&gt;Hi Amit, thanks for providing the links &amp;amp; info etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure I see which ones relate to the measure I am after.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For clarity:&lt;/P&gt;&lt;P&gt;- A Date table exists&lt;/P&gt;&lt;P&gt;- A filter will be on the visual for a Month-Year (this is dynamic, they user can select from mutiple years and all months&lt;/P&gt;&lt;P&gt;- The Relationship is there and active between the Date table and Publications (data) table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is addressing the complexity around having to include another field in the DAX that is offset by 1 year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I have:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Reportable Publications YTD PY = 
VAR PubYearPY = MAX(PUBLICATIONS[PUB_YEAR]) - 1
VAR CurrentMonth = MONTH(MAX(Dates[Date]))

VAR Result = 
CALCULATE(DISTINCTCOUNT(PUBLICATIONS[PUBLICATION_ID]),
    ALL(Dates),
    ALL(PUBLICATIONS[PUB_YEAR]),
    FILTER(PUBLICATIONS,  
        PUBLICATIONS[PUB_YEAR] = PubYearPY &amp;amp;&amp;amp;
        (PUBLICATIONS[PUB_YEAR] = YEAR(PUBLICATIONS[REPORTABLE_DATE_ADJUSTED]) &amp;amp;&amp;amp;
        MONTH(PUBLICATIONS[REPORTABLE_DATE_ADJUSTED]) &amp;lt;= CurrentMonth )
        ),
    USERELATIONSHIP(PUBLICATIONS[REPORTABLE_DATE_ADJUSTED],Dates[Date])
)

--Return PubYearPY
--Return CurrentMonth
Return Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PubYearPY returns the correct (prior) PUB_YEAR&lt;/P&gt;&lt;P&gt;CurrentMonth returns the correct month # based on the filder selection on the page&lt;/P&gt;&lt;P&gt;However the Result is blank.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jul 2022 10:41:38 GMT</pubDate>
    <dc:creator>PhilC</dc:creator>
    <dc:date>2022-07-18T10:41:38Z</dc:date>
    <item>
      <title>Prior Year measure, with an additional field to consider</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-measure-with-an-additional-field-to-consider/m-p/2643676#M77730</link>
      <description>&lt;P&gt;I am looking to see if there is a more efficient approach for the measure below, and also want another measure to calculate a Prior Year (PY) version. (to be used in YoY variance).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data represents publications, which have an attribute called PUB_YEAR. This is a single year value. There is also a REPORTABLE_DATE_ADJUSTED field which represents the date the record was captured in the system and had a RELATIONSHIP with the Dates table. The REPORTABLE_DATE_ADJUSTED can occur well after the PUB_YEAR, ie in subsequent years, so these need to be ignored in the YTD counts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measure below is designed to represent the YTD position for any given PUB_YEAR, such that as different months are selected from the dates table, the YTD counts update, and if a month after the current month is selected, then earlier years will increase but the current year will not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Reportable Publications YTD = 
VAR PubYearLast = MAX(Dates[Year])
VAR PubYearFirst = PubYearLast - 3

VAR Result = 
CALCULATE(DISTINCTCOUNT(PUBLICATIONS[PUBLICATION_ID]),
    ALL(Dates),
    FILTER(PUBLICATIONS, 
            PUBLICATIONS[PUB_YEAR] = YEAR(PUBLICATIONS[REPORTABLE_DATE_ADJUSTED]) &amp;amp;&amp;amp;
            MONTH(PUBLICATIONS[REPORTABLE_DATE_ADJUSTED]) &amp;lt;= MONTH(MAX(Dates[Date]))
    ),
    USERELATIONSHIP(PUBLICATIONS[REPORTABLE_DATE_ADJUSTED],Dates[Date])
)

Return Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot work out the logic for a # Reportable Publications YTD PRIOR YEAR measure.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;It needs to present the value from the prior PUB YEAR (ie if PUB_YEAR is 2022, it should show the count for the YTD for the 2021 PUB YEAR. ie excluding any activity not only happening after the reporting month from the previous year, but also any activity in months up to the reporting month in subsequent years. So, I do not think functions like DATAADD and SAMEPERIODLASTYEAR will assist due to having to move back one year with PUB_YEAR as well as with the REPORTABLE_DATE_ADJUSTED.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;See screenshot for example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ve&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;&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;Will work on mocking up a detailed dataset to help, but posting now in case someone can help based on the measure displayed above&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 04:58:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-measure-with-an-additional-field-to-consider/m-p/2643676#M77730</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2022-07-18T04:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Prior Year measure, with an additional field to consider</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-measure-with-an-additional-field-to-consider/m-p/2644375#M77773</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="82755" data-lia-user-login="PhilC" class="lia-mention lia-mention-user"&gt;PhilC&lt;/a&gt; , First of Date table should be used in filter, slicer and visual for all period related stuff&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example&lt;/P&gt;
&lt;P&gt;YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use relationship example&lt;/P&gt;
&lt;P&gt;calculate( calculate( SUM(Sales[Sales Amount]),USERELATIONSHIP ('Sales'[CreateDate], 'Date'[Date])),DATESYTD('Date'[Date]))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;YTD another option&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;YTD = &lt;BR /&gt;var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())&lt;BR /&gt;var _min = eomonth(_max,-1*MONTH(_max))+1 &lt;BR /&gt;return&lt;BR /&gt;CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a userelationship measure in place of net&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;prefer to measure with userealtionship and then use it with TI&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :&lt;A href="https://youtu.be/OBf0rjpp5Hw" target="_blank"&gt;https://youtu.be/OBf0rjpp5Hw&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4" target="_blank"&gt;https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4&lt;/A&gt;&lt;BR /&gt;&lt;FONT size="2"&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;A href="https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions" target="_blank"&gt;radacad&lt;/A&gt; &lt;A href="https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/" target="_blank"&gt;sqlbi&lt;/A&gt; &lt;A href="https://www.youtube.com/playlist?list=PLPaNVDMhUXGYLz-w8ERQOo3KYARs7GgG-" target="_blank"&gt;My Video Series&lt;/A&gt; Appreciate your Kudos. &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 09:23:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-measure-with-an-additional-field-to-consider/m-p/2644375#M77773</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-07-18T09:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Prior Year measure, with an additional field to consider</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-measure-with-an-additional-field-to-consider/m-p/2644610#M77780</link>
      <description>&lt;P&gt;Hi Amit, thanks for providing the links &amp;amp; info etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure I see which ones relate to the measure I am after.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For clarity:&lt;/P&gt;&lt;P&gt;- A Date table exists&lt;/P&gt;&lt;P&gt;- A filter will be on the visual for a Month-Year (this is dynamic, they user can select from mutiple years and all months&lt;/P&gt;&lt;P&gt;- The Relationship is there and active between the Date table and Publications (data) table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is addressing the complexity around having to include another field in the DAX that is offset by 1 year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I have:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Reportable Publications YTD PY = 
VAR PubYearPY = MAX(PUBLICATIONS[PUB_YEAR]) - 1
VAR CurrentMonth = MONTH(MAX(Dates[Date]))

VAR Result = 
CALCULATE(DISTINCTCOUNT(PUBLICATIONS[PUBLICATION_ID]),
    ALL(Dates),
    ALL(PUBLICATIONS[PUB_YEAR]),
    FILTER(PUBLICATIONS,  
        PUBLICATIONS[PUB_YEAR] = PubYearPY &amp;amp;&amp;amp;
        (PUBLICATIONS[PUB_YEAR] = YEAR(PUBLICATIONS[REPORTABLE_DATE_ADJUSTED]) &amp;amp;&amp;amp;
        MONTH(PUBLICATIONS[REPORTABLE_DATE_ADJUSTED]) &amp;lt;= CurrentMonth )
        ),
    USERELATIONSHIP(PUBLICATIONS[REPORTABLE_DATE_ADJUSTED],Dates[Date])
)

--Return PubYearPY
--Return CurrentMonth
Return Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PubYearPY returns the correct (prior) PUB_YEAR&lt;/P&gt;&lt;P&gt;CurrentMonth returns the correct month # based on the filder selection on the page&lt;/P&gt;&lt;P&gt;However the Result is blank.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 10:41:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Prior-Year-measure-with-an-additional-field-to-consider/m-p/2644610#M77780</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2022-07-18T10:41:38Z</dc:date>
    </item>
  </channel>
</rss>

