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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jfpalumbo123
Frequent Visitor

PREVIOUSMONTH returning blanks

Just trying to use PREVIOUSMONTH function but I always get blanks. Looking through other posts...I am using Auto Time Intelligence and my column is set to type of Date and I see the Date Hierarchy. I cannot set my date dimension as Date Table because I have date gaps in the table entries. 

Measure = LASTDATE(Divs[Date].[Date]) works as expected but
Measure = PREVIOUSMONTH(Divs[Date].[Date]) returns Blank

No filters, no slicer, nothing obvious to me.

I am actually trying to do the following, but cannot get PREVIOUSMONTH to work
Last Month = CALCULATE(SUM(Divs[Amount]),PREVIOUSMONTH(Divs[Date].[Date]))

Why??

Thanks in advance. 
1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @jfpalumbo123 ,

 

I think you'd better create a calendar table.

 

This is my test table:

vyadongfmsft_0-1669270337886.png

 

If I don't create a calendar table, I will get blank result:

CurrentMonth_sales = CALCULATE(SUM('Table'[Sales]),FILTER('Table','Table'[Month] = SELECTEDVALUE('Table'[Month])))

PreviousMonth_sales_1 = CALCULATE(SUM('Table'[Sales]),PREVIOUSMONTH('Table'[Date]))

vyadongfmsft_1-1669270431772.png

 

If I create a calendar table:

CalendarTable = ADDCOLUMNS(CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),"Month",MONTH([Date]))

vyadongfmsft_2-1669270517488.png

 

and create relationship between two tables:

vyadongfmsft_3-1669270554794.png

 

You will get correct result:

PreviousMonth_sales_2 = CALCULATE(SUM('Table'[Sales]),PREVIOUSMONTH('CalendarTable'[Date]))

vyadongfmsft_4-1669270651135.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
jfpalumbo123
Frequent Visitor

Looks like that is what I needed. TYVM!

v-yadongf-msft
Community Support
Community Support

Hi @jfpalumbo123 ,

 

I think you'd better create a calendar table.

 

This is my test table:

vyadongfmsft_0-1669270337886.png

 

If I don't create a calendar table, I will get blank result:

CurrentMonth_sales = CALCULATE(SUM('Table'[Sales]),FILTER('Table','Table'[Month] = SELECTEDVALUE('Table'[Month])))

PreviousMonth_sales_1 = CALCULATE(SUM('Table'[Sales]),PREVIOUSMONTH('Table'[Date]))

vyadongfmsft_1-1669270431772.png

 

If I create a calendar table:

CalendarTable = ADDCOLUMNS(CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),"Month",MONTH([Date]))

vyadongfmsft_2-1669270517488.png

 

and create relationship between two tables:

vyadongfmsft_3-1669270554794.png

 

You will get correct result:

PreviousMonth_sales_2 = CALCULATE(SUM('Table'[Sales]),PREVIOUSMONTH('CalendarTable'[Date]))

vyadongfmsft_4-1669270651135.png

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

FreemanZ
Super User
Super User

try not to use Auto Time Intelligence and try to build your own Date table. The easiest way is to create a new table with the code below:

Date = CALENDARAUTO ( )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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