cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Souza Frequent Visitor
Frequent Visitor

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

Accepted Solutions
Souza Frequent Visitor
Frequent Visitor

Re: Compare current month with previous month in same period

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
Tahreem24 Member
Member

Re: Compare current month with previous month in same period

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!
amitchandak Super Contributor
Super Contributor

Re: Compare current month with previous month in same period

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)))

 

 

Souza Frequent Visitor
Frequent Visitor

Re: Compare current month with previous month in same period

@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.

Highlighted
Souza Frequent Visitor
Frequent Visitor

Re: Compare current month with previous month in same period

@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.

Souza Frequent Visitor
Frequent Visitor

Re: Compare current month with previous month in same period

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

Helpful resources

Announcements
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 309 members 2,981 guests
Please welcome our newest community members: