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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
admin11
Memorable Member
Memorable Member

YTD expression return Last yr value , Can it use button to switch to display Current year value ?

Hi All

 

I have a issue , when i my Date expression :-

CALENDAR(Date(2003,01,01),date(2021,12,31))

 

Today is Jan 18 2022 ,My YTD expression below it will return Last year Total sales amount.

 

Sales YTD =
var _max = date(year(today())-0,month(today()),day(today()))
return
TOTALYTD(('SALES'[SALES_]),dateadd('DATE'[Date],-0,year),'DATE'[Date]<=_max)

When i change the date expression to :-

 

DATE =
CALENDAR ( "2003,1,1", TODAY() )
I can view the above YTD expression , it will display 2022 YTD amount.
 
May i know how it is possible to insert one more button , so that same YTD expression , can display 2021 YTD or 2022 YTD mount ? 
 
Paul  
1 ACCEPTED SOLUTION
dvl_ctaul
Helper I
Helper I

Hi Paul,

Couple of things: Have you gone through the process of marking your Date table as a calendar table? (Right click the table name from your Fields pane > Mark as date table > Mark as date Table > select your unique date column)

 

If so, then you can simplify your expression to just be:

CALCULATE ( 
[SALES],
DATESYTD('DATES'[Date])
)

 

Then you can add a year slicer to your canvas. Whichever year you select will give you the YTD value for that value for that year. 

 

Cheers

View solution in original post

2 REPLIES 2
dvl_ctaul
Helper I
Helper I

Hi Paul,

Couple of things: Have you gone through the process of marking your Date table as a calendar table? (Right click the table name from your Fields pane > Mark as date table > Mark as date Table > select your unique date column)

 

If so, then you can simplify your expression to just be:

CALCULATE ( 
[SALES],
DATESYTD('DATES'[Date])
)

 

Then you can add a year slicer to your canvas. Whichever year you select will give you the YTD value for that value for that year. 

 

Cheers

@dvl_ctaul 

This is the best reply i get in 2022. Thank you very much.  it is what i am looking for.

Paul

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors