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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Sivadster
Frequent Visitor

LY YTD and YTD

Hi,

I'm trying to create a measure that returns my sales from the parallel period LY to this exact date. 

i.e : if today is the 09/05/24 I would like to retrieve sales from 01/01/23 to 09/05/23.

 

And compare that with the parallel period this year.

 

These are the measures I use:

LYYTD Sales = TOTALYTD([Total Sales],DATEADD('Calendar'[Date],-1,YEAR),ALL('Calendar'))
YTD Sales = TOTALYTD(SALE[Total Sales],'Calendar'[Date],all('Calendar'))
 
The LYYTD measure returns all sales from 01/01/23 to 31/05/23  instead of to 09/05/23.
 
Thanks,
 
Daniel
 
2 ACCEPTED SOLUTIONS

Hi,

Thanks for your reply.

The LY YTD is solved....

For some reason the YTD stops on April and doesn't show the May sales.

 

This is the code I wrote:  

YTD Sales = TOTALYTD(sum(SALES[data    ]),'Calendar'[Date])

View solution in original post

@Sivadster share your sample dataset, and try to create correct connection between Calendar Table and your data table, i.e make sure column type should be DATE for both related columns

View solution in original post

4 REPLIES 4
fahadqadir3
Resolver III
Resolver III

@Sivadster You can achieve this by using the following measure, you need to create a Calendar Table:

Date Table = CALENDAR(MIN('Table'[Date]),MAX('Table'[Date]))

Sales LYTD =

TOTALYTD(SUM('Table'[Sales]),
DATEADD('Date Table'[Date],-1,YEAR))

 

LYTD.png

Sales YTD =

TOTALYTD(SUM('Table'[Sales]), 'Date Table'[Date])

Power BI File:

LYTD.pbix

 

Regards,

Fahad Qadir

Did I answer your question? Mark my post as a solution!

Hi,

Thanks for your reply.

The LY YTD is solved....

For some reason the YTD stops on April and doesn't show the May sales.

 

This is the code I wrote:  

YTD Sales = TOTALYTD(sum(SALES[data    ]),'Calendar'[Date])

@Sivadster share your sample dataset, and try to create correct connection between Calendar Table and your data table, i.e make sure column type should be DATE for both related columns

Hi, found a problem that caused it. Your solution works.

Thanks

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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