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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Compare current month with previous month in same period

Hello, could you help me?
I want to create a measure to bring from the previous month only the quantity up to the same period of the current month. As shown in the image below.
If the most current date you have is October 23rd, I want to create a measure that will bring me the total by September 23rd.

The measure I want to create is the column (TOTAL PREVIOUS MONTH PERIOD (23)) from the example.
I tried with PREVIOUSMONTH and DATEADD, but I was unsuccessful. Always brings the full date of the previous month.

Attached or dataset for example

http://ge.tt/6OiCmKy2

 

CALCULATE MES ATE O DAY.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I managed to solve. Below solution I found.

 

MEDIDA =
VAR LastDate = LASTDATE('DATASET'[DATE])
VAR UltimoDay = DAY(LastDate)
VAR StartLastDate = DATE(YEAR(LastDate);MONTH(LastDate)-1;1)
RETURN
CALCULATE(SUM('DATASET'[QTD]);DATESINPERIOD(CALENDAR[Data];StartLastDate;UltimoDay;DAY))

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

I managed to solve. Below solution I found.

 

MEDIDA =
VAR LastDate = LASTDATE('DATASET'[DATE])
VAR UltimoDay = DAY(LastDate)
VAR StartLastDate = DATE(YEAR(LastDate);MONTH(LastDate)-1;1)
RETURN
CALCULATE(SUM('DATASET'[QTD]);DATESINPERIOD(CALENDAR[Data];StartLastDate;UltimoDay;DAY))
amitchandak
Super User
Super User

do you continuous dates? The previous month, datemtd etc will work only when you have continuous dates.

 

Last month MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date Filer],-1,MONTH)))

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak  That way, I also did but he brings the month before full, I need to bring with the same period of days, in this case until the 23rd of both months.

Tahreem24
Super User
Super User

You can calculate the previous month values using below dax formula:
MEASURE = CALCULATE (SUM(SALES), PREVOIUSMONTH(DATE))

Let me know if I am getting your query right.

Please give Kudos and accept this as a solution!
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

@Tahreem24  That way, I also did but he brings the month before full, I need to bring with the same period of days, in this case until the 23rd of both months.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.