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
DarylM
Helper II
Helper II

Sales total to current date from previous year

Hi, 

I am struggling to find a way to compare a true total of sales for last year to current date this year. 

I am using the "sameperiodlastyear" function, but it returns the entire total for last year. 

 

PYTD Sales = CALCULATE([Total Sales],SAMEPERIODLASTYEAR('Unlabeled Jarred Goods Sales'[Date].[Date]))

 

I need to show the total of sales up to the last date of the current years sales. 

 

Any thoughts?

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @DarylM,

 

Please try this formula:

PYTD Sales =
    CALCULATE (
        [Total Sales],
        PARALLELPERIOD (
            LASTNONBLANK ( 'Unlabeled Jarred Goods Sales'[Date], 1 ),
            -1,
            YEAR
        )
    )

If you have any question, please feel free to ask.

 

Thanks,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @DarylM,

 

Please try this formula:

PYTD Sales =
    CALCULATE (
        [Total Sales],
        PARALLELPERIOD (
            LASTNONBLANK ( 'Unlabeled Jarred Goods Sales'[Date], 1 ),
            -1,
            YEAR
        )
    )

If you have any question, please feel free to ask.

 

Thanks,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
DarylM
Helper II
Helper II

To elaborate, I am date product sales 1/1/15 through 10/25/16. I need to show the sales for 2015 up to 10/25. These dates will continue to populate as we go through the year. I am having trouble finding a way to calculate this with DAX. 

Hi,

 

as long as you only compare years I have a solution here.  In this thread I am looking for a solution that also works with months, quarters etc as well.

 

Sammy

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.