Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerBI_RD
Frequent Visitor

SAMEPERIODLASTYEAR total sums up entire month

I have searched for a solution for this issue, but so far none of them have worked for me. Here's the scenario:

 

I have a report that calculates the Sales YTD-1 using this measure:

 

Sales YTD -1 =
VAR LastDayAvailable =
    CALCULATE (
        MAX ( Facts[Date] ),
        ALL ( Facts )
    )
VAR CurrentDates =
    FILTER (
        VALUES ( date_table[Date] ),
        date_table[Date] <= LastDayAvailable
    )
VAR Result =
    CALCULATE ( [Sales YTD],
        SAMEPERIODLASTYEAR ( CurrentDates )
    )
RETURN
    Result
 
This gives me the result I expect: the total for this year matches with the date of today, looking one year back.
 
PowerBI_RD_0-1685617320815.png

 

However when I copied this measure to a new report, with basically the same set up (facts table connected to date table, max date is today) the total gives me a number for the entire month of June, instead of 1-1-2022 till 1-6-2022.
 
PowerBI_RD_1-1685617320669.png

 

So same measure, different results. There are no filters on the measure nor on the page. 
 
Is there something extremely obvious that I'm missing here? I know SAMEPERIODLASTYEAR behaves this way (calculating the whole month of the previous year) but somehow that's not the case with my first table.
2 REPLIES 2
amitchandak
Super User
Super User

@PowerBI_RD , You should try meausres like

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

 

Make sure the date table fields are used in measure, visual and slicer

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Unfortunately that makes no difference for the total, that's still calculating the entire month.

 

PowerBI_RD_0-1685687263540.png

 

 

My question basically is why is there a differerence between the way YTD-1 behaves with regards to the total, with one report showing the total up until today, and the other one showing the total till the end of the current month. With these reports having the same formulas and basically the same setup.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.