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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Trolleri
Helper I
Helper I

Comparing MTD this month vs WHOLE month last year

I am trying to compare sales so far MTD with the same month previous year, but i want the sum for the whole month previous year. Right now i only get MTD up to todays date for last year too.
 
Amount_SameMonthLastYear_MTD = CALCULATE([Amount_MTD];SAMEPERIODLASTYEAR('DimDate'[Date]))
1 ACCEPTED SOLUTION
AUaero
Responsive Resident
Responsive Resident

Missing a parentheses to close the MAX function.  This should work:

 

Amount_SameMonthLastYear_MTD =
CALCULATE(
    [Amount_MTD],
	DATESINPERIOD(
		DimDate[Date],
		EOMONTH(max(DimDate[Date],-13)+1,
		1,
		MONTH
	)
)

View solution in original post

4 REPLIES 4
AUaero
Responsive Resident
Responsive Resident

What about this?

Amount_SameMonthLastYear_MTD =
CALCULATE(
    [Amount_MTD],
	DATESINPERIOD(
		DimDate[Date],
		EOMONTH(max(DimDate[Date],-13)+1,
		1,
		MONTH
	)
)

I get "the syntax for 1 is incorrect"

AUaero
Responsive Resident
Responsive Resident

Missing a parentheses to close the MAX function.  This should work:

 

Amount_SameMonthLastYear_MTD =
CALCULATE(
    [Amount_MTD],
	DATESINPERIOD(
		DimDate[Date],
		EOMONTH(max(DimDate[Date],-13)+1,
		1,
		MONTH
	)
)

Sorry, still doesnt work, get the same error.

Cant see any difference in the 2 code snippets you posted, tried to add a paranthesis after the max function but still the same errror.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.