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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

How to display Last Year sales but not accumulated?

Hello, I am trying to do a report based on YTD sales from previous years, compared to this year.

 

If I use this formula

 

YTD de MONTO_USD = TOTALYTD(SUM('APPEND_VEPEDDET'[MONTO_USD]),SAMEPERIODLASTYEAR('CALENDARIO'[Date]))

 

I can actually see the last year sales, but when I apply this value into a line chart visual to compare last year sales (blue line) with the current year sales (light blue line), I can see that previous year sales are accumulated each month, which distorts the comparison since I need to display total sales for each month individually, not accumulated (this year's sales are displayed correctly)

 

jmr78_1-1597321884050.png

 

Is it possible to do this? I have been trying for a few days already, but I coul not find a workaround.

 

Thank you!!

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You need use ytd measure in SAMEPERIODLASTYEAR. Make sure calendar table is marked as date table

 

You can use measures 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"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year 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"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
//Only year vs Year, not a level below

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

 

https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try to change your measure like so:

YTD de MONTO_USD =
CALCULATE (
    SUM ( 'APPEND_VEPEDDET'[MONTO_USD] ),
    SAMEPERIODLASTYEAR ( 'CALENDARIO'[Date] )
)

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , You need use ytd measure in SAMEPERIODLASTYEAR. Make sure calendar table is marked as date table

 

You can use measures 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"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year 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"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
//Only year vs Year, not a level below

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

 

https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

 

Anonymous
Not applicable

That worked great! Thank you very much @amitchandak😀

 

One more question: the last year's YTD shows the amount for the whole month. For example, when I see sales from August 2019, the value represents the sales from the 1st to the 31st of given month. Is there any way to show the sales up to today's date one year ago (Aug 14th), so I compare sales from 01-14 AUG 2020 to 01-14 AUG 2019?

 

Thank you!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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