<?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: Retrieve Measures for Previous Event (not date based) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/796307#M4698</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="43047" data-lia-user-login="xmark" class="lia-mention lia-mention-user"&gt;xmark&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Sep 2019 22:42:11 GMT</pubDate>
    <dc:creator>Nathaniel_C</dc:creator>
    <dc:date>2019-09-18T22:42:11Z</dc:date>
    <item>
      <title>Retrieve Measures for Previous Event (not date based)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/795173#M4670</link>
      <description>&lt;P&gt;Hi all, I have a model which is centred around "events" (such as a festival or sporting day), these events repeat year on year, but the dates/days shift each year, so traditional same-time-last-year measures dont really work for my client.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My event table contains a field called "PreviousEventId"&amp;nbsp; which referes to the previous time the event ran (which could be last year, or could be last week!). This field is a reference to the same event table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created the basic measures for fact tables (ticket sales for example) - and now I need to create the "same-time-last-event" measure - but am really stuck on how to achieve this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is some data for example puposes only:&lt;/P&gt;&lt;P&gt;Event Table:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;EventId&lt;/TD&gt;&lt;TD&gt;Description&lt;/TD&gt;&lt;TD&gt;PreviousEventId&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;EV112&lt;/TD&gt;&lt;TD&gt;2018 School Sports Day&lt;/TD&gt;&lt;TD&gt;(null)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;EV119&lt;/TD&gt;&lt;TD&gt;2019 School Sports Day&lt;/TD&gt;&lt;TD&gt;EV112&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tickets:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SaleId&lt;/TD&gt;&lt;TD&gt;Amount&lt;/TD&gt;&lt;TD&gt;EventId&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S11100&lt;/TD&gt;&lt;TD&gt;10.50&lt;/TD&gt;&lt;TD&gt;EV112&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S11101&lt;/TD&gt;&lt;TD&gt;15.50&lt;/TD&gt;&lt;TD&gt;EV112&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S11102&lt;/TD&gt;&lt;TD&gt;28&lt;/TD&gt;&lt;TD&gt;EV112&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S11103&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;EV119&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;S11104&lt;/TD&gt;&lt;TD&gt;150&lt;/TD&gt;&lt;TD&gt;EV119&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My desired output would be a report like so:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Event&lt;/TD&gt;&lt;TD&gt;Curent Sales Total&lt;/TD&gt;&lt;TD&gt;Sales Total Last Event&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2018 School Sports Day&lt;/TD&gt;&lt;TD&gt;250&lt;/TD&gt;&lt;TD&gt;54&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above are very simplistic examples, but the real effort for me is around the measure for the "Sales Total Last Event"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 04:29:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/795173#M4670</guid>
      <dc:creator>xmark</dc:creator>
      <dc:date>2019-09-18T04:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Measures for Previous Event (not date based)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/796246#M4697</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="43047" data-lia-user-login="xmark" class="lia-mention lia-mention-user"&gt;xmark&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just to clarify in the output is it 2018 or 2019 School Sports Day?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nathaniel&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 20:58:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/796246#M4697</guid>
      <dc:creator>Nathaniel_C</dc:creator>
      <dc:date>2019-09-18T20:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Measures for Previous Event (not date based)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/796307#M4698</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="43047" data-lia-user-login="xmark" class="lia-mention lia-mention-user"&gt;xmark&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 22:42:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/796307#M4698</guid>
      <dc:creator>Nathaniel_C</dc:creator>
      <dc:date>2019-09-18T22:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Measures for Previous Event (not date based)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/796320#M4699</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="43047" data-lia-user-login="xmark" class="lia-mention lia-mention-user"&gt;xmark&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Part of this was pretty straightforward, but ended up creating a new table with SUMMARIZE to gather the previous Sales Amount.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Current Sales Total = CALCULATE(Sum(Tickets[Amount]),Filter((Events),Events[EID] =Max(Events[EID])))&lt;/PRE&gt;&lt;P&gt;This works as we filter for the event.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Previous Event = CALCULATE(Max(Events[P_EID]),fILTER(Events,MAX(Events[EID]) = MAX(Events[EID])))&lt;/PRE&gt;&lt;P&gt;I checked this with an additional Evebt in Events.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Sales Total Last Event = CALCULATE(MAX(NewTable[Sales]),Filter(NewTable,NewTable[EventID] = [Previous Event]))&lt;/PRE&gt;&lt;P&gt;This works as we don't have undo filter, and the amount is already summed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This the new table with a quick summary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;No relationship on the new table, so we can harvest and the filter does not affect it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Used your example tables, with maybe an abbreviation here and there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if you have any questions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.&lt;BR /&gt;Nathaniel&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;</description>
      <pubDate>Wed, 18 Sep 2019 23:05:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/796320#M4699</guid>
      <dc:creator>Nathaniel_C</dc:creator>
      <dc:date>2019-09-18T23:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Measures for Previous Event (not date based)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/796374#M4700</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="159166" data-lia-user-login="Nathaniel_C" class="lia-mention lia-mention-user"&gt;Nathaniel_C&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your reasponse, I appreacite the help! I can kind of follow what you did, but I am not sure why you did it that way...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;A couple of follow-up questions:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I have a set of other dimension tables linking from the Tickets table (such as Category1, Category2, Classification, Status, many others...) I would ideally like to use these dimensions too whenever I use the new measure for previous event sales. But if I create a new table using summarize like you have done, I am limited in what I can do, is that correct (since the summarize table only contains 2 columns, I would have to add columns to the table for each dimension I wanted to include)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had a go at this myself last night, but Im not sure if I am on the right track, here is my DAX:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;previousData = 
VAR previousSelectedEventId = SELECTEDVALUE(Event[PreviousEventId])
RETURN
CALCULATE(
	SUM(Tickets[Amount]),
    ALLEXCEPT(Classification, Category1, Category2, Category3),  
    Attendance[EventId] = previousSelectedEventId
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This appears to work, but my concern is that since I am clearing the filter on Classification, Category1,&amp;nbsp;Category2, and&amp;nbsp;Category3... if my end user uses this measure on another dimension table that I have not included in the ALLEXCEPT function, it will not work as expected... is that correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 01:02:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/796374#M4700</guid>
      <dc:creator>xmark</dc:creator>
      <dc:date>2019-09-19T01:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Measures for Previous Event (not date based)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/797514#M4722</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="43047" data-lia-user-login="xmark" class="lia-mention lia-mention-user"&gt;xmark&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Working on a project, but will get back to this soon. In the meantime, here is my&amp;nbsp;&lt;A href="https://1drv.ms/u/s!AgCd7AyfqZtExEZriK095w6YaIu3?e=mESMgh" target="_blank" rel="noopener"&gt;PBIX&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Nathaniel&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 01:07:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Retrieve-Measures-for-Previous-Event-not-date-based/m-p/797514#M4722</guid>
      <dc:creator>Nathaniel_C</dc:creator>
      <dc:date>2019-09-20T01:07:46Z</dc:date>
    </item>
  </channel>
</rss>

