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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

PreviousMonth Calculation

Hello,

 

I have a very simple messure:

TotalSalesBlue = SUMX(FILTER('Sales','Sales'[COLOR]="BLUE"),'Sales'[AMT])

 

Sales Table is connect with Date Table via DateID.

 

I'm trying to find Only PreviousMonth, PreviousQuarter Data using Following formula:

PreviousMonthBlueSlaes= CALCULATE ([TotalSalesBlue] , PREVIOUSMONTH(DATE[Date_Id]))

 

I'm geeting all the months, but I'm only looking for previous month sum.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Hi,

 

Explore relative dates filters


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

 

If you modify your TotalSalesBlue measure to this, do you get the correct result.

 

=CALCULATE(SUM('Sales'[AMT]),'Sales'[COLOR]="BLUE")


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Even after modifying the result I get all month


1- Changed messured as you suggested, still getting all months as shown below. I'm need to only get 9/30/2018 data.

post.jpg

hi, @Anonymous

You may try to this way as below:

Step1:

Add a year month column in date table

Year Month Number = YEAR ( 'Date'[Date] ) * 100 + MONTH ( 'Date'[Date] ) 

16.JPG

Step2:

modify the formula

PreviousMonthBlueSlaes = CALCULATE ([TotalSalesBlue] , PREVIOUSMONTH('Date'[Date]), 'Date'[Year Month Number]=YEAR(TODAY())*100+MONTH(TODAY())-2)

Result:

BeforeBeforeAfterAfter

 

Best Regards,

Lin

 

 

 

 

 

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

Hi,

 

Explore relative dates filters


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.