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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.