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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rynoh22
New Member

Previous Year sales measure not working

Hello,

 

I have a set of data with sales, customers, sales reps, and month & year. I'm trying to pull last the previous year sales with

Prior Year Sales = CALCULATE(
	SUM(
		'Sales Data'[Sales]),
		DATEADD(
			'Sales Data'[Date],
			-1,
			YEAR
		)
)

I'm checking it in a matrix set up as Rows: Year, Quarter, Month. Values: Sales and Prior Year Sales.

 

 

The sales column is just fine. The Previous Year Sales column is populating as blanks everywhere except a total at the bottom.

 

Please help me with this.


Ryan

1 ACCEPTED SOLUTION
v-huizhn-msft
Employee
Employee

Hi @rynoh22,

As I tested, you'd better create a Calendar table, create a relationship between Calendar table and Sales Data table.

Create measure using the following formula.

Prior Year Sales = CALCULATE(
	SUM(
		'Sales Data'[Sales]),
		DATEADD(
			'Calendar'[Date],
			-1,
			YEAR
		)
)

 

Create a table visual, select Calendar[Date].Year, Calendar[Date].Quarter as rows, you will get expectd result.

1.PNG2.PNG

 


If you have other issues, please feel free to ask.

Best Regards,
Angelia

View solution in original post

4 REPLIES 4
hemamaleni
Helper I
Helper I

I am having similar issue. Very simple file yet not able to get the YoY values. Can you help me understand where I am wrong?

 

YOY_picture.png

v-huizhn-msft
Employee
Employee

Hi @rynoh22,

As I tested, you'd better create a Calendar table, create a relationship between Calendar table and Sales Data table.

Create measure using the following formula.

Prior Year Sales = CALCULATE(
	SUM(
		'Sales Data'[Sales]),
		DATEADD(
			'Calendar'[Date],
			-1,
			YEAR
		)
)

 

Create a table visual, select Calendar[Date].Year, Calendar[Date].Quarter as rows, you will get expectd result.

1.PNG2.PNG

 


If you have other issues, please feel free to ask.

Best Regards,
Angelia

Hey 
I have followed the query. But table is depicting the next year as well. 

Can you help with that?

 

That worked. I think my issue was that I was using the Date field from the Sales Data Table instead of the Date table.

Thank you @v-huizhn-msft

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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