Forum Discussion

TWijnen90's avatar
TWijnen90
New Member
2 years ago
Solved

SAMEPERIODLASTYEAR returns values from this year

Hi,

 

I'm using SAMEPERIODLASTYEAR to compare the number of incoming mails per month to the same month the previous year, but it appears to add the numbers from this year to last year.

 

The set-up is very simple: I have a table (Mail) which contains the number of mails (Amount), the type of mail (Category) and the date on which they came in (Date). Besides that I have a date table (tbl_date).

 

I have 2 formulas, Total This Year and Total Last Year:

CALCULATE([Totaal], tbl_date[Year] = YEAR(TODAY()))
and
CALCULATE([Totaal], SAMEPERIODLASTYEAR(tbl_date[Date]))
NB: [Totaal] is just the sum of the Amount.
 
For some reason, when I put these in a matrix, is takes the values from January and February this year, and adds them to last year.

January and February last year should just be empty, just like the remaining months for this year are. 

Now, we've only started to keep track of the number since May last year, that's why March and April are missing. And since it's only February this year, we've yet to complete a full year. Maybe that's where it goes wrong, I don't know. Any ideas?
  • Adjust your DAX as...

     

    CALCULATE(
        [Totaal], 
        SAMEPERIODLASTYEAR(tbl_date[Date]),
        tbl_date[Year] = YEAR(TODAY()) - 1
    )

1 Reply

  • amustafa's avatar
    amustafa
    Solution Sage

    Adjust your DAX as...

     

    CALCULATE(
        [Totaal], 
        SAMEPERIODLASTYEAR(tbl_date[Date]),
        tbl_date[Year] = YEAR(TODAY()) - 1
    )