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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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