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
Anonymous
Not applicable

Year over Year calculation default to value with latest date in the data set

Hi All,

I've searched high and low and can't find an answer to this question. I need to add a card to my dashboard that shows the YOY calculation. I used the quick measure option and it works like a charm. My issue though, is that I want the card to default to the value for the latest date in the data set (before any date is selected in the slicer). 

In my example, I have dates going from 1/1/2020 through 1/1/2022. The card should show the YOY Diff value, based on the date selected in the slicer. As the dates are selected in the date slicer, the values are correct in the card. But as a default, I want the card to show the 1/1/2022 value of 122%. (the latest date in the dataset). Next month, the default value will be the 2/1/2022 value.  I don't want to set a filter on the card because it needs to be dynamic. Can anyone help me please? 

Attached is a screenshot of the data set, card and slicer.  Much appreciated!!

Tinar1029

PBI YOY Card Question.png

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@Anonymous  You can use the LASTDATE function to find the most recent transaction in your fact table. 

 

So add an IF condition to your measure:

 

VAR _LastTransaction = LASTDATE ( TblSampleData[Date] )

VAR _SelectedDate = MAX( DateDim[Date] )

RETURN

IF ( _SelectedDate < _LastTransaction, [YoY Measure], CALCULATE ( [YoY Measure] , DateDim[Date] = _LastTransaction ) )


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

1 REPLY 1
AllisonKennedy
Super User
Super User

@Anonymous  You can use the LASTDATE function to find the most recent transaction in your fact table. 

 

So add an IF condition to your measure:

 

VAR _LastTransaction = LASTDATE ( TblSampleData[Date] )

VAR _SelectedDate = MAX( DateDim[Date] )

RETURN

IF ( _SelectedDate < _LastTransaction, [YoY Measure], CALCULATE ( [YoY Measure] , DateDim[Date] = _LastTransaction ) )


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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
Top Kudoed Authors