Forum Discussion

RobThrive's avatar
RobThrive
Resolver I
6 years ago
Solved

This year vs Last year

How can I show a set of values (based on user selected date range) on one line, and a 2nd line which shows the data for the same time (months) but of the previous year to the user selected date range...
  • RobThrive's avatar
    6 years ago

    Solved my own problem.

    In case any other new to PowerBI/Dax comes this way. I had to create a new table and used CALENDARAUTO() to generate that.

    I then linked it to the date of events in my dataset.

     

    I hadn't set the measure below to take from the new date table that I created

    Previous Year - # of events = CALCULATE('EventsTable'[Events - number of], SAMEPERIODLASTYEAR(EventsTable[DateOfEvent]))

     When corrected to

    Previous Year - # of events = CALCULATE('EventsTable'[Events - number of], SAMEPERIODLASTYEAR(DateTable[Dates]))

    and I used that date table in the visual, things worked ! :)