<?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: Booking and Travel date shenanigans in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2087872#M47498</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp; - wow, thank you! That is working for the previous year. I've removed the bits that were not being used:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Revenue PY = 
VAR today23 =
    YEAR ( TODAY () ) - 1
        &amp;amp; FORMAT ( TODAY (), "MM" )
        &amp;amp; FORMAT ( DAY ( TODAY () ), "DD" )
RETURN
    CALCULATE (
        [Revenue],
        DATEADD ( 'Date'[Date], -1, YEAR ),
        FILTER ( ALL ( Travel ), Travel[BookingDateKey] &amp;lt; VALUE ( today23 ) )
    )&lt;/LI-CODE&gt;&lt;P&gt;So in your other reply you asked about Sept 14th. What I want to do is go back one fiscal year, rather than one calendar year. So now I need a way to calculate today23 as one fiscal year back, and change the filter in the calculate statement to also go one year back.&lt;/P&gt;&lt;P&gt;I'll give that a go today and let you know how I get on.&lt;/P&gt;</description>
    <pubDate>Tue, 21 Sep 2021 06:53:39 GMT</pubDate>
    <dc:creator>DuncanP</dc:creator>
    <dc:date>2021-09-21T06:53:39Z</dc:date>
    <item>
      <title>Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2082159#M47237</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm really hoping that someone out there might have done something similar to what I'm trying to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on YoY revenue calculations for a travel company. They have bookings which have a booking date and a travel date. I want to show this year's revenue vs last year's revenue, but have it display by travel date. At the same time, in order to give a fair comparison, I want the last year calculation to include only bookings that had been made up to the same day last year. In other words, something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Revenue TY/LY at September 17:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Month of Travel&lt;/TD&gt;&lt;TD&gt;Revenue&lt;/TD&gt;&lt;TD&gt;Revenue LY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;September&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;£234,999&lt;/TD&gt;&lt;TD&gt;£194,838&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;October&lt;/TD&gt;&lt;TD&gt;£76,877&lt;/TD&gt;&lt;TD&gt;£68,948&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;November&lt;/TD&gt;&lt;TD&gt;£43,494&lt;/TD&gt;&lt;TD&gt;£41,949&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;December&lt;/TD&gt;&lt;TD&gt;£32,674&lt;/TD&gt;&lt;TD&gt;£29,598&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously, a standard LY calculation would show much higher numbers for Revenue LY, as it would include bookings that were made throughout September to December. But in order to see how we are doing versus the same point last year, we only want to include bookings that had been made before one year ago today.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried adapting the calculations on&amp;nbsp;&lt;A href="https://www.daxpatterns.com/custom-time-related-calculations/" target="_blank" rel="noopener"&gt;Dax Patterns&lt;/A&gt;&amp;nbsp;but with no luck so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sure I can't be the first person to want to do this sort of thing, so if there's anyone out there who's done something similar, or knows someone who has, I'd love to hear from you.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 08:27:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2082159#M47237</guid>
      <dc:creator>DuncanP</dc:creator>
      <dc:date>2021-09-17T08:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2082982#M47270</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="5505" data-lia-user-login="DuncanP" class="lia-mention lia-mention-user"&gt;DuncanP&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's not clear. I'd suggest that you create a very simple example with just several bookings (maybe even 2 will suffice?) and show here how the calculation you want would work step by step. Then I'm sure it'll be much easier to get the idea about what you want and you'll get an answer almost in no time. Just show a good and simple example. The simplest there is to demonstrate the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 14:46:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2082982#M47270</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-17T14:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2086268#M47433</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for replying. I've put a file&amp;nbsp;&lt;A href="https://1drv.ms/u/s!AvRL2YBsS-X9zJRMHR2Rd-WefngMnQ?e=4nJ5EQ" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;that shows the issue. It contains bookings that were made up to Sept 13 2021. On the left is a visual showing this year and the previous year by travel date. On the right is a visual filtered to last year, and for bookings before made Sept 14 2020.&lt;/P&gt;&lt;P&gt;I want the PY measure to be able to show the same figures as the visual on the right.&lt;/P&gt;&lt;P&gt;But you can see that the PY calculation gives the same figures up to August, but from September onwards it is gradually further and further away.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you see what I'm trying to do now?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 12:40:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2086268#M47433</guid>
      <dc:creator>DuncanP</dc:creator>
      <dc:date>2021-09-20T12:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2086385#M47437</link>
      <description>&lt;P&gt;Is your issue resolved?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 13:31:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2086385#M47437</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-20T13:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2086526#M47441</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;No, it's not, and I've still got no idea where to start. I've created a Power BI file&amp;nbsp;&lt;A href="https://1drv.ms/u/s!AvRL2YBsS-X9zJRMHR2Rd-WefngMnQ?e=4nJ5EQ" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;that illustrates the problem, and I've described the issue in my reply to&amp;nbsp;Anonymous&lt;/a&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 14:35:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2086526#M47441</guid>
      <dc:creator>DuncanP</dc:creator>
      <dc:date>2021-09-20T14:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2087740#M47495</link>
      <description>&lt;P&gt;ou tell me september 14th from where you picking up. What is the condition for that date.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 05:47:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2087740#M47495</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-21T05:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2087803#M47497</link>
      <description>&lt;P&gt;Try this code this will calculate your values as compared to today in last year.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;PY Revenue = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR selectedtravelkey =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;MAX ( Travel[BookingDateKey] ),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;USERELATIONSHIP ( 'Date'[DateKey], Travel[BookingDateKey] )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DATEADD ( 'Date'[Date], -1, YEAR )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR today23 =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;YEAR ( TODAY () ) - 1&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;amp; FORMAT ( TODAY (), "MM" )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;amp; FORMAT ( DAY ( TODAY () ), "DD" )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[Revenue],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DATEADD ( 'Date'[Date], -1, YEAR ),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;FILTER ( ALL ( Travel ), Travel[BookingDateKey] &amp;lt; VALUE ( today23 ) )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 21 Sep 2021 06:18:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2087803#M47497</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-21T06:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2087872#M47498</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp; - wow, thank you! That is working for the previous year. I've removed the bits that were not being used:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Revenue PY = 
VAR today23 =
    YEAR ( TODAY () ) - 1
        &amp;amp; FORMAT ( TODAY (), "MM" )
        &amp;amp; FORMAT ( DAY ( TODAY () ), "DD" )
RETURN
    CALCULATE (
        [Revenue],
        DATEADD ( 'Date'[Date], -1, YEAR ),
        FILTER ( ALL ( Travel ), Travel[BookingDateKey] &amp;lt; VALUE ( today23 ) )
    )&lt;/LI-CODE&gt;&lt;P&gt;So in your other reply you asked about Sept 14th. What I want to do is go back one fiscal year, rather than one calendar year. So now I need a way to calculate today23 as one fiscal year back, and change the filter in the calculate statement to also go one year back.&lt;/P&gt;&lt;P&gt;I'll give that a go today and let you know how I get on.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 06:53:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2087872#M47498</guid>
      <dc:creator>DuncanP</dc:creator>
      <dc:date>2021-09-21T06:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2087891#M47500</link>
      <description>&lt;P&gt;If this resolve your query please give kudos &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;. Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 07:04:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2087891#M47500</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-21T07:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2105017#M48067</link>
      <description>&lt;P&gt;So, an update.&lt;/P&gt;&lt;P&gt;I managed to create an adjusted revenue measure that does what I wanted in terms of calculating the figure at an equivalent point each year. I haven't yet managed to work out a corresponding PY calculation, but it seems OK for being able to show all years with fair comparisons between them. The code for the measure is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Revenue Adjusted = 
SUMX (
    /* sum each fiscal year separately */
    VALUES ( 'Date'[Fiscal Year Number] ),
    /* get the last booking date available (could use another date table to allow the user to select this value) */
    VAR LastBookingDate =
        CALCULATE ( MAX ( Travel[BookingDateKey] ), ALL ( Travel ) )
    /* get the fiscal day of year for the last selected date */
    VAR FiscalDayOfYear =
        LOOKUPVALUE (
            'Date'[Day of Fiscal Year Number],
            'Date'[DateKey], LastBookingDate
        )
    /* get the current fiscal year being aggregated */
    VAR CurrentFiscalYear = 'Date'[Fiscal Year Number]
    /* work out the date in the current year that corresponds to the fiscal day */
    VAR CutoffDate =
        LOOKUPVALUE (
            'Date'[DateKey],
            'Date'[Day of Fiscal Year Number], FiscalDayOfYear,
            'Date'[Fiscal Year Number], MAX ( 'Date'[Fiscal Year Number] )
        ) 
    /* get a table of fiscal days of year for summing up (I think) */
    VAR DaysSelected =
        CALCULATETABLE (
            VALUES ( 'Date'[Day of Fiscal Year Number] ),
            REMOVEFILTERS (
                'Date'[Working Day],
                'Date'[Day of Week],
                'Date'[Day of Week Number]
            )
        )
    RETURN
        /* calculate the revenue for the currently selected fiscal year across each day filtering the travel table by the cutoff date corresponding to that fiscal year */
        CALCULATE (
            [Revenue],
            'Date'[Fiscal Year Number] = CurrentFiscalYear,
            DaysSelected,
            FILTER ( ALL ( Travel ), Travel[BookingDateKey] &amp;lt; VALUE ( CutoffDate ) ),
            ALLEXCEPT ( 'Date', 'Date'[Working Day], 'Date'[Day of Week] )
        )
)&lt;/LI-CODE&gt;&lt;P&gt;And the corresponding Power BI file is&amp;nbsp;&lt;A href="https://1drv.ms/u/s!AvRL2YBsS-X9zJYBQBTQUQ0_vkUsBA" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 08:25:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2105017#M48067</guid>
      <dc:creator>DuncanP</dc:creator>
      <dc:date>2021-09-29T08:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Booking and Travel date shenanigans</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2105054#M48069</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You can see in my post below that I managed to extend the calculation to a general one that works out the equivalent revenue in any year. I didn't manage to get a PY calculation to work in the end as I am using a week based calendar, not a normal one so can't use the DATEADD bit to go back in time. I haven't yet worked out how to translate the measure into a 364 day calendar so that's still to do.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 08:34:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Booking-and-Travel-date-shenanigans/m-p/2105054#M48069</guid>
      <dc:creator>DuncanP</dc:creator>
      <dc:date>2021-09-29T08:34:51Z</dc:date>
    </item>
  </channel>
</rss>

