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

Show Current Year Sales & Previous Year Sales in Chart

Mackie_0-1602205097286.png

 

I would like to show current year sales & previous year sales like the picture above.

If I do not select slicer, it looks fine.

But when I select some choice in the slicer, previous year sales does not change like below.

That's a problem. How should I change previous year sales measure? Thank you.

 

sales_pre_year =
VAR startDate = MINX('financials', [Date].[Date])
VAR endDate = MAXX('financials', [Date].[Date])
RETURN

SUMX(FILTER(ALL('financials'), [Date].[Date] >= DATE(YEAR(startDate)-1, MONTH(startDate), DAY(startDate)) && [Date].[Date] <= DATE(YEAR(endDate)-1, MONTH(endDate), DAY(endDate))), [ Sales])

 

Mackie_1-1602205208955.png

 

PBIX file is uploaded here: https://sharpsynappx-my.sharepoint.com/:u:/g/personal/mackie_sharpsynappx_onmicrosoft_com/ETL97-Q3k8...

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Mackie , You can use monthly or Tailing year measure

 

example

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Mackie , You can use monthly or Tailing year measure

 

example

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

Thank you, @amitchandak. Your answer is helpful.

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.

Top Solution Authors