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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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

 

 

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.