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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Why PREVIOUSMONTH shows blank values ?

Hi,

 

I try to show last month sales by customers but the PREVIOUSMONTH function gives me a blank column.

 

The PARALLELPERIOD function gives me a sum of the sales for last month AND last year last month. (August 2017 + August 2018).

 

The DATEADD function gives me the same result as the PARALLELPERIOD function.

These results are obviously not what I expect.

 

(Yes I do have a date table with a relationship between my date table and my sales table.)

 

Here's a screenshot of my report.

 

Could someone help ?

 

Thank you

Example1.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

Since you dont have a slicer selected in the current page to identify which year and if you always want it to default to the todays date the below formula works for you.

 

= CALCULATE(SUM(Sales[Revenue]),DATESBETWEEN('Calendar'[Date],EOMONTH(TODAY(),-14)+1,EOMONTH(TODAY(),-13)))

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous,

You need to add dates to your table to display the previous month since you are using Dates[Date].

But if you always want to see the previous month irrespective of the month you selected you can use below formula to compute the same.

prevmonth.JPG

Anonymous
Not applicable

Hi clokeshreddy,

 

Since I created a viz with months in which I selected the current month, it works !

 

Now I'm trying to create a "Last Month Last Year" measure. The DAX formula I entered is :

 

Last Month Last Year = CALCULATE([Last Month Sales];SAMEPERIODLASTYEAR(Dates[Date]))

 

It gives me the same result as my "Last Month Sales" measure.

 

Do you have any idea why I'm getting this ?

 

Thank you very much !

Anonymous
Not applicable

Hi @Anonymous,

Since you dont have a slicer selected in the current page to identify which year and if you always want it to default to the todays date the below formula works for you.

 

= CALCULATE(SUM(Sales[Revenue]),DATESBETWEEN('Calendar'[Date],EOMONTH(TODAY(),-14)+1,EOMONTH(TODAY(),-13)))

Anonymous
Not applicable

It works perfectly !! Thank you so much !!!

Greg_Deckler
Super User
Super User

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.