Last Year To Date

  • Last Year To Date

    Posted by DSC Communities on November 25, 2019 at 4:38 am
    • Andy Robinson

      Member

      November 25, 2019 at 4:38 AM

      Hi all,

      I’m trying to compare sales values last to date against this year to date.
      I have a table called Sales and a date table called Calendar. They are linked on Order Date from Sales to Date in Calendar, single from Calendar to Sales.

      If I use the following Measure, it works:

      LYTD Sell Value = TOTALYTD( SUM(Sales[Line Value]), DATEADD(Sales[Order Date], -365, DAY))

      UNTIL I filter on any of the fields in the Sales table, which don’t have a sale exactly 365 days ago.

      But I know I should be using the Calendar date field, so I tried:

      LYTD Sell Value = TOTALYTD( SUM(Sales[Line Value]), DATEADD(Calendar[Date], -365, DAY))

      Yet this doesn’t work at all.

      Does anyone have any suggestions? Anything would be greatly appreciated.

      thanks

      ——————————
      Andy
      ——————————

    • Lorenzo Vercellati

      Member

      November 25, 2019 at 4:57 AM

      Hi,

      Total Sell Value = SUM(Sales[Line Value]
      YTD Sell Value= TOTALYTD([Total Sell Value], Calendar[Date])
      LYTD Sell Value = CALCULATE([YTD Sell Value], SAMEPERIODLASTYEAR(Calendar[Date]))

      Regards
      Lorenzo

      ——————————
      Lorenzo Vercellati
      PowerBI Solution Architect
      SolidQ
      Milan
      3382819866
      ——————————
      ——————————————-

    • Vishesh Jain

      Member

      December 2, 2019 at 5:03 AM

      Hi ,

      Just a side-note for the DATEADD() function. It is tricky function and I try to avoid using it.
      For DATEADD() you need to have all the calendar dates that are in your calculation, in your calendar table. If your result dates do not exist in your calendar table, it will give an error.

      So try avoiding it and rather just subtract? the number of days directly from the date.

      However, the solution that Lorenzo provided is the best way to go.

      Thank you,

      ——————————
      Vishesh Jain
      Owner
      VR Construction
      ——————————
      ——————————————-

    • Andy Robinson

      Member

      December 3, 2019 at 3:45 AM

      thank you very much. really appreciate the help

      ——————————
      Andy Robinson
      ——————————
      ——————————————-

    DSC Communities replied 6 years, 4 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘Last Year To Date’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!