Time Intelligence using ParallelPeriod, DateAdd & SamePeriodLastYear

  • Time Intelligence using ParallelPeriod, DateAdd & SamePeriodLastYear

    Posted by DSC Communities on May 9, 2020 at 8:32 am
    • Chong SM

      Member

      May 9, 2020 at 8:32 AM

      Hi,

      I am trying to compare sales use the above 3 time intelligent functions.
      I believe there is nothing wrong with the DAX measures but I just couldn’t get all the past year sales to appear on the table.Ā  E.g. 2017 sales should appear on 2018 across the 3 functions, and so on. File is attached for checking.

      Any advice is appreciated.

      Thanks!

      ——————————
      Chong SM
      ——————————

    • Vincent Lacomme

      Member

      May 9, 2020 at 10:19 AM

      Hi Chong,

      You need a separate date table (you can check this excellent article on SQLBI : https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/).

      Enclosed is the file where I only added a date table. I didn’t have to change your measures and now the visuals are working.

      ——————————
      Vincent L.
      Chartered accountant – Expert-comptable
      ——————————
      ——————————————-

    • Chong SM

      Member

      May 10, 2020 at 8:47 AM

      Hi Vincent,

      Thanks for the pointer. I have one more question regarding the dashboard (see my file attached).
      Let’s say I want to make the ParallelPeriod, SamePeriodLastYear and DateAdd measures responding to the Region filter. As you can see I got an error message (see below) when the SamePeriodLastYear and DateAdd measures are added:

      Even the ParallelPeriod measure is also not giving the correct reading after filtering.

      Not sure if I have missed out anything, or there are some limitations in the measures, or I need to re-write the measures in a different way.

      Thanks!

      ——————————
      Chong SM
      ——————————
      ——————————————-

    • Lutz Bendlin

      Member

      May 11, 2020 at 8:18 AM

      As it says in the error message your dates table need to have contiguous date entries (without any gaps). Make sure to point your DAX calculations to the right table, observe filter direction in your data model (avoid bi-directional where possible)Ā  and make your dates table larger than your fact data by at least a year on either side.Ā  Both the source and the destination of a date computation must be covered by the dates table range.

      ——————————
      Lutz
      ——————————
      ——————————————-

    • Chong SM

      Member

      May 12, 2020 at 8:59 PM

      Thanks for sharing.

      I also found out I need to add .[Date] to DateAdd and SamePeriodLastYear measures.Ā E.g.
      Ā 

      DateAdd = CALCULATE([TotalSales], DATEADD(Sales[Date].[Date], -1, YEAR))

      SamePeriodLastYear = CALCULATE([TotalSales], SAMEPERIODLASTYEAR(Sales[Date].[Date]))

      Without the .[Date], the measures will give the above error message.

      ——————————
      Chong SM
      Data Analyst
      ——————————
      ——————————————-

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

Sorry, there were no replies found.

The discussion ‘Time Intelligence using ParallelPeriod, DateAdd & SamePeriodLastYear’ 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!