cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Previous Year sales measure not working

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

2 REPLIES 2
Highlighted
Microsoft
Microsoft

Re: Previous Year sales measure not working

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

Highlighted
New Member

Re: Previous Year sales measure not working

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
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors