<?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 Need help with SAMEPERIODLASTYEAR function and a filtered master calendar in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1367777#M24855</link>
    <description>&lt;P&gt;I have a measure like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count of Appointments Same Period Last Year = CALCULATE(COUNTA(Appointments[Status]),SAMEPERIODLASTYEAR('Master Calendar'[Date]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data relationships are like this: Master Calendar Period filters Master Calendar filters Appointments&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In reporting visualisation if I have the Master Calendar 'Date' column as a slicer, I can get a nice matrix table showing current and previous year appointment numbers like so:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is if I use the Calendar Period table as a date slicer, I no longer get the previous year period numbers, unless I include the previous year in the slicer too:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that this is happening because I am filtering my Master Calendar due to my selection in the Calendar Period table so the measure can't calculate numbers for the last year period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now as a workaround I tell people they need to select a Calendar Period that spans over 1 year in order to display previous years numbers along side but I would like to present the data as in the top table screenshot while still using an easy to choose time period slicer as I already have in the Calendar Period table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to keep the date hierarchy available so users can choose a date, week, month, quarter, year etc and the DAX calculation needs to work with all those potentional groupings, which is why I love the sameperiodlastyear function as it takes care of that for me.&lt;/P&gt;&lt;P&gt;I like the Calendar Period slicer as does management, to quickly pick a time period so I don't want to push onto them the more cumbersome Master Calendar date slicer.&lt;/P&gt;&lt;P&gt;I'm thinking there should be a DAX solution but can't get it.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Sep 2020 06:40:45 GMT</pubDate>
    <dc:creator>SteveCarter1</dc:creator>
    <dc:date>2020-09-14T06:40:45Z</dc:date>
    <item>
      <title>Need help with SAMEPERIODLASTYEAR function and a filtered master calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1367777#M24855</link>
      <description>&lt;P&gt;I have a measure like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count of Appointments Same Period Last Year = CALCULATE(COUNTA(Appointments[Status]),SAMEPERIODLASTYEAR('Master Calendar'[Date]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data relationships are like this: Master Calendar Period filters Master Calendar filters Appointments&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In reporting visualisation if I have the Master Calendar 'Date' column as a slicer, I can get a nice matrix table showing current and previous year appointment numbers like so:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is if I use the Calendar Period table as a date slicer, I no longer get the previous year period numbers, unless I include the previous year in the slicer too:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that this is happening because I am filtering my Master Calendar due to my selection in the Calendar Period table so the measure can't calculate numbers for the last year period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now as a workaround I tell people they need to select a Calendar Period that spans over 1 year in order to display previous years numbers along side but I would like to present the data as in the top table screenshot while still using an easy to choose time period slicer as I already have in the Calendar Period table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to keep the date hierarchy available so users can choose a date, week, month, quarter, year etc and the DAX calculation needs to work with all those potentional groupings, which is why I love the sameperiodlastyear function as it takes care of that for me.&lt;/P&gt;&lt;P&gt;I like the Calendar Period slicer as does management, to quickly pick a time period so I don't want to push onto them the more cumbersome Master Calendar date slicer.&lt;/P&gt;&lt;P&gt;I'm thinking there should be a DAX solution but can't get it.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 06:40:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1367777#M24855</guid>
      <dc:creator>SteveCarter1</dc:creator>
      <dc:date>2020-09-14T06:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with SAMEPERIODLASTYEAR function and a filtered master calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1367845#M24856</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="238520" data-lia-user-login="SteveCarter1" class="lia-mention lia-mention-user"&gt;SteveCarter1&lt;/a&gt;&amp;nbsp;- There is.&amp;nbsp;You may find this helpful - &lt;A href="https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008" target="_blank"&gt;https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The basic technique, you figure out the date of last year min and max from the current user selections. You use ALL or ALLSELECTED or REMOVEFILTERS to override your filter context for date and then filter back down to the range you want.&amp;nbsp;@ me if you have trouble implementing and post sample data as text in a table so I can mock up your situation and get you a more specific answer.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 07:00:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1367845#M24856</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-09-14T07:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with SAMEPERIODLASTYEAR function and a filtered master calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1367898#M24858</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="238520" data-lia-user-login="SteveCarter1" class="lia-mention lia-mention-user"&gt;SteveCarter1&lt;/a&gt;&amp;nbsp; I would suggest adding REMOVEFILTERS ( 'Master Calendar Periods' ) within CALCULATE (can use ALL in place of REMOVEFILTERS if you like).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your selections on 'Master Calendar' / 'Master Calendar Periods' still determine the initial dates that are visible in the visual, but the "Last Year" measure is no longer constrained by any filters from 'Master Calendar Periods'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oh, and your 'Master Calendar' table should be marked as a Date Table if it isn't already.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count of Appointments Same Period Last Year =
CALCULATE (
    COUNTA ( Appointments[Status] ),
    SAMEPERIODLASTYEAR ( 'Master Calendar'[Date] ),
    REMOVEFILTERS ( 'Master Calendar Periods' )
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;It worked in a test model at my end. Does it work for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 07:17:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1367898#M24858</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2020-09-14T07:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with SAMEPERIODLASTYEAR function and a filtered master calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1367902#M24859</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="238520" data-lia-user-login="SteveCarter1" class="lia-mention lia-mention-user"&gt;SteveCarter1&lt;/a&gt; , I am not sure of the role of a master calendar period. But make sure the master calendar is marked as date calendar Right-click on the table. There is an option.&lt;/P&gt;
&lt;P&gt;you can also try&lt;/P&gt;
&lt;P&gt;Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))&lt;/P&gt;
&lt;P&gt;2 Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-2,Year))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Power BI — YTD &lt;BR /&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a&lt;/A&gt;&lt;BR /&gt;Power BI — QTD &lt;BR /&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839&lt;/A&gt;&lt;BR /&gt;Power BI — MTD &lt;BR /&gt;&lt;A href="https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e" target="_blank"&gt;https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e&lt;/A&gt;&lt;BR /&gt;Power BI — WTD &lt;BR /&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;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 07:16:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1367902#M24859</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-09-14T07:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with SAMEPERIODLASTYEAR function and a filtered master calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368155#M24871</link>
      <description>Apart from what &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt; says, you could also INCORPORATE the Master Calendar Periods into the main calendar, Master Calendar. Of course, you would then not be able to mark the table as a date table but you would have one table instead of two, which would be more intuitive for the end user. I know there is a 1:* relationship between the tables. THIS DOES NOT PREVENT YOU FROM MERGING THEM.</description>
      <pubDate>Mon, 14 Sep 2020 08:34:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368155#M24871</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-14T08:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with SAMEPERIODLASTYEAR function and a filtered master calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368541#M24877</link>
      <description>&lt;P&gt;Thanks for taking the time to reply.&lt;/P&gt;&lt;P&gt;I use the calendar period table to create arbitary relative time frames that can be quickly chosen from the slicer instead of requiring the end user to manually pick out a date range. For example I can create a 'Last 13 Months' period selection that would filter my master calendar to the last 13 months. I know this can be acheived without any modelling using the filter pane and relative date selection but to be frank that is simply too hard for the vast majority of my end users to deal with. Seeing a fixed set of options in a drop down seems to me, based on my client base and feedback, as the most effective solution.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 10:17:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368541#M24877</guid>
      <dc:creator>SteveCarter1</dc:creator>
      <dc:date>2020-09-14T10:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with SAMEPERIODLASTYEAR function and a filtered master calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368549#M24878</link>
      <description>&lt;P&gt;As usual Greg, an extremely comprehensive reply and anyone coming across this thread can only be wiser for clicking through to read your blog article.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 10:19:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368549#M24878</guid>
      <dc:creator>SteveCarter1</dc:creator>
      <dc:date>2020-09-14T10:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with SAMEPERIODLASTYEAR function and a filtered master calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368554#M24879</link>
      <description>&lt;P&gt;Yours is by far the most succint and correct answer. Thank you.&lt;/P&gt;&lt;P&gt;I think I was having a 'can't see the forest amonst the trees' moment.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 10:22:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368554#M24879</guid>
      <dc:creator>SteveCarter1</dc:creator>
      <dc:date>2020-09-14T10:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with SAMEPERIODLASTYEAR function and a filtered master calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368556#M24880</link>
      <description>"I use the calendar period table to create arbitary relative time frames that can be quickly chosen from the slicer instead of requiring the end user to manually pick out a date range."&lt;BR /&gt;&lt;BR /&gt;Sorry but I don't get it.... How relevant the above is to what I wrote? Because I can't see any link. You can create your relative frames also in one big date table. You don't need 2 tables to do that.</description>
      <pubDate>Mon, 14 Sep 2020 10:22:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368556#M24880</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-14T10:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with SAMEPERIODLASTYEAR function and a filtered master calendar</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368625#M24883</link>
      <description>&lt;P&gt;I need to re-think my date table logic. I was under the impression for a table marked as a date table I needed a sequence of consecutive dates with no duplicates.&lt;/P&gt;&lt;P&gt;For it to be in one big table where I can choose 1 column for my slicer I would have thought I'd need 1 column with the period name in it then that period name I want chosen against each date, but because 1 date can be associated with more than 1 period name - e.g. the dates for 'Last Week' are the same for 'All Time' and 'This Year' and 'Last Year to Date' etc - I would have thought I would need the same date duplicated for each period name.&lt;/P&gt;&lt;P&gt;As an example for 1st Jan 2020 I have this in my Calendar Period table:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I generate that table in M using the master calendar table as a reference then create a new column for each period name and mark each date as a null if it does not apply or 1 if it applies to that period name then I unpivot the table so I end up with 2 columns like you see above.&lt;/P&gt;&lt;P&gt;Setting a relationship between those 2 tables on the date then lets me filter my master date table based on the period name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't see how I can achieve this in a single master date table with a set of unique dates.&lt;/P&gt;&lt;P&gt;I'll be sure to look further into it though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the feedback.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 10:43:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-help-with-SAMEPERIODLASTYEAR-function-and-a-filtered-master/m-p/1368625#M24883</guid>
      <dc:creator>SteveCarter1</dc:creator>
      <dc:date>2020-09-14T10:43:56Z</dc:date>
    </item>
  </channel>
</rss>

