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
Highlighted
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
Super User II
Super User II

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!
Super User IV
Super User IV

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

 

 





Did I answer your question? Mark my post as a solution!
In case it does not help, please provide additional information and mark me with @
My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP,
HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Super User! Linkedin


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.

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.

Highlighted
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
Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors