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
heathernicole
Continued Contributor
Continued Contributor

SAMPLEPERIODLASTYEAR pulling FULL year - not previous YTD

I am trying to compare YTD sales to Previous YTD sales. 

 

YTD formula:

 

SalesYTD = 
CALCULATE (
[Incoming Total Sales], 
FILTER (
ALL ( 'Calendar - Transaction Date' ), 
'Calendar - Transaction Date'[Transaction Date Year Number] = MAX ( 'Calendar - Transaction Date'[Transaction Date Year Number] )
&& 'Calendar - Transaction Date'[Transaction Date] <= MAX ( 'Calendar - Transaction Date'[Transaction Date])
)
)
PYTD Sales = 
CALCULATE (
    [Incoming Total Sales], 
    FILTER (
        ALL ( 'Calendar - Transaction Date' ), 
        'Calendar - Transaction Date'[Transaction Date Year Number] = (MAX ( 'Calendar - Transaction Date'[Transaction Date Year Number]) -1)
            && 'Calendar - Transaction Date'[Transaction Date] <= MAX ( 'Calendar - Transaction Date'[PY Date])
    )
)

However - the PYTD measure (no matter what variation I do) is pulling the FULL year for last year

 

Even using SAMPLEPERIODLASTYEAR. I can NOT figure out why it's doing that rather than pulling JUST the data for YTD LAST year. 

Previous Year Sales (Incoming) = CALCULATE([Incoming Total Sales], SAMEPERIODLASTYEAR('Calendar - Transaction Date'[Transaction Date]))

ANY ideas as to WHY it's behaving this way? It's the same on EVERY report I have. 

~heathernicoale
1 ACCEPTED SOLUTION

https://community.powerbi.com/t5/Desktop/Prior-year-year-to-date-sales/m-p/173509#M75776 

 

So the solution from this forum question did the trick perfectly... it doesn't quite answer why the other methods didn't work - but for now, it gives the data I need.

 

here's the formula modified; it's quite a bear of a formula: lol 

 

PYTD Sales = 
CALCULATE(
[Incoming Total Sales],
SAMEPERIODLASTYEAR(
DATESYTD('Calendar - Transaction Date'[Transaction Date])
),
FILTER(
ALL('Calendar - Transaction Date'),
'Calendar - Transaction Date'[Transaction Date Month Number] <= (MONTH(NOW())-1)
)
)+
CALCULATE(
[Incoming Total Sales],
SAMEPERIODLASTYEAR(
DATESYTD('Calendar - Transaction Date'[Transaction Date])
),
FILTER(
ALL('Calendar - Transaction Date'),
'Calendar - Transaction Date'[Transaction Date Month Number] = MONTH(NOW())
&& 'Calendar - Transaction Date'[Transaction Date Day Number] <= DAY(NOW())
)
)
~heathernicoale

View solution in original post

10 REPLIES 10

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.