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

Current month vs last year's current month

Hello, im trying to do some calculations with value from current month  and compare it with las years same month as i refresh my data.

I tried the following measure to get Sales from last year's march but, it only showed  total sales of 2018:

CALCULATE(sum(TableX[Sales]);YEAR(TableX[WorkDate]=2018);month(today())=MONTH(TableX[WorkDate))
Example Table:


2019-03-21 11_12_42-Libro1 - Excel.png

1 ACCEPTED SOLUTION
v-danhe-msft
Employee
Employee

Hi @hgzelaya ,

Based on my test, you could refer to below measures:

Previous = var a=YEAR(MAX('Table1'[WorkDate]))-1
return CALCULATE(SUM(Table1[Sales]),FILTER(ALL('Table1'),'Table1'[Year]=a))
Difference = CALCULATE(SUM(Table1[Sales]))-[Previous]

Result:

1.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-danhe-msft
Employee
Employee

Hi @hgzelaya ,

Based on my test, you could refer to below measures:

Previous = var a=YEAR(MAX('Table1'[WorkDate]))-1
return CALCULATE(SUM(Table1[Sales]),FILTER(ALL('Table1'),'Table1'[Year]=a))
Difference = CALCULATE(SUM(Table1[Sales]))-[Previous]

Result:

1.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HotChilli
Super User
Super User

The measure looks ok. 

Here's my test

Annotation 2019-03-21 March.png

 

Quick tip : to get your questions answered , paste real data not a photo of the data

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.