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
gmat
Helper I
Helper I

Seeking Assistance with Year-to-Date (YTD) Comparison in Power BI Matrix

I am having issues trying to do a comparison of FY2023 YTD and FY 2024 YTD in the same Matrix. For example, I want to be able to pull in the YTD units for January and February from 2023 in a comparison to current year YTD information... I was able to do a month to month comparison by creating a new measure: 

 

 

Past27Days_Units = CALCULATE(SUM('Summary Query'[UNIT_COUNT]),FILTER('Summary Query','Summary Query'[COMM_CLOSE_DT] >= TODAY() - 27 || ('Summary Query'[COMM_CLOSE_DT] >=TODAY() - 27 - 365 &&'Summary Query'[COMM_CLOSE_DT] < TODAY() - 365)))
 
This does a good job of bringing in the the MTD comparison for january but it will not consider january for 2023 when we pull in the february data. Does anyone have any experience adding a new measure for YTD of previous year or any other simple way of doing this that does not require updating when we roll into 2025?
2 REPLIES 2
amitchandak
Super User
Super User

@gmat , Try two measures like

 

YTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1*MONTH(_max))+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

LYTD =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _max = Date(Year(_max1)-1, Month(_max1), Day(_max1))
var _min = eomonth(_max,-1*MONTH(_max))+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

This was very helpful however having two measure messes with my matrix. Am I able to keep everything uniform and get rid of the double column sub headers like shown on the left? 

 

gmat_0-1709060378643.png

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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