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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
LyncoData1
Helper I
Helper I

PY Sales Actually Pull Exact Same Period Last Year

Hi there,

 

The below DAX Function is the function for same period last year, but I only want to see the values up to the March 30th of last year. I want to see the exact same time frame YOY and I would like my data to populate automatically as the days progress throughout the year. Please see measure below. PBI is saying that I have too few arguments for DatesBetween. 

 

 

SamePeriodLastYear =
CALCULATE(
[Net Sales],
SAMEPERIODLASTYEAR(
DATESBETWEEN(
FILTER(
ALLSELECTED(FactNetSales),
FactNetSales[Posting Date]< TODAY()))))

 

4 REPLIES 4
amitchandak
Super User
Super User

Sample period last year and Trailing measure with Date dimension will work, for that, you need to make some date is selected on the page

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"))
This Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD((ENDOFYEAR('Date'[Date])),"12/31"))

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

 

or try like

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"12/31"),'Date'[Date]<=today())

Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"),'Date'[Date]<=date(year(today()-1),month(today()),day(today()))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I'm sorry, no this did not work. 

 

However, I attempted another measure like this but now I am experiencing missing data since there were no sales on certain dates this year in 2020.  All I want is my data to stop on the current day (today) (max day). For example if today was March 25th 2020 then all I would want to pull is Prior Year Jan 1 2019 to March 25 2019. The exact same time period. I would not want to pull entire month or year. Just pull net sales up current date. Below is the formula I used and the missing data 

 

SamePeriodLatYear =
VAR MaxDate = EDATE(CALCULATE(MAX('FactNetSales'[Posting Date]),ALL(FactNetSales)),-12)
RETURN
CALCULATE(
[Net Sales],
FILTER(SAMEPERIODLASTYEAR('DimCalendar'[DateKey]),'DimCalendar'[DateKey]<= MaxDate
))
 
 
 

March.PNG

Hi @LyncoData1 ,

Please try this one.

SamePeriodLatYear =
VAR tod =
    TODAY ()
VAR lastyear =
    DATE ( YEAR ( tod ) - 1, MONTH ( tod ), DAY ( tod ) )
VAR firstday =
    DATE ( YEAR ( tod ) - 1, 1, 1 )
RETURN
    CALCULATE (
        [Net Sales],
        FILTER (
            ALL ( 'DimCalendar' ),
            'DimCalendar'[DateKey] <= lasytear
                && 'DimCalendar'[DateKey] >= firstday
        )
    )

 

If it doesn't meet your requirement,  kindly share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to One Drive for Business and share the link here.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

This did not work. However, I did use the two measures below that gave me what I wanted for Net Sales. However, now I need help with finding YTD MTD Sales based on the measures listed below to ensure they fall into the current "TODAY" time frame. Would you have any insight ?

 

Actual SamePeriodLastYear =
CALCULATE (
[Net Sales],
FILTER ( 'DimCalendar', 'DimCalendar'[Month] <= MONTH( ( TODAY () ) )
))
 
Actual SamePeriodLastYear1 =
CALCULATE([Actual SamePeriodLastYear],(SAMEPERIODLASTYEAR('DimCalendar'[DateKey])) )
 
PY.PNG

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Users online (2,228)