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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Estefania89
New Member

PREVIOUSMONTH

Hello! Attempt to calculate the sales of the previous month using this function:

SP= CALCULATE ( SUM ( Table1 [number ] ) ; previousMonth (Table 2 [DATA ] ) )

 

However, the function does not return values

1 ACCEPTED SOLUTION

Finally you can use your measure:

 

SP= CALCULATE ( SUM ( Table1 [number ] ) ; previousMonth (CalendarTable [DATE ] ) )




Lima - Peru

View solution in original post

8 REPLIES 8
kcantor
Community Champion
Community Champion

This particular exession requires a date table related to the fact table. Are you using a date table?

Check out this link

http://www.mrexcel.com/forum/power-bi/842725-previous-month-date-dax-syntax.html





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you for answering!

 

i have a data table and a data fact, how ever no relationship  was detected!

 

 

 

Hi, can you post a screenshot with tables and relationship?.

 




Lima - Peru

2016-06-28.png

2016-06-28 (1).png

Hi @Estefania89 you need a date Table with each day like a calendar.

 

To create a calendar table you can use:

 

Create a new Table (From Modeling)

 

CalendarTable=Calendar("01/01/2015";31/12/2016") you can change the dates according to your tables.

 

Next, create a relationship between date columns on your tables  and Calendar Table.

 

 

 

 




Lima - Peru

Finally you can use your measure:

 

SP= CALCULATE ( SUM ( Table1 [number ] ) ; previousMonth (CalendarTable [DATE ] ) )




Lima - Peru

Perfect!

 

It works now. Thanks so much for all your help!

 

Anonymous
Not applicable

Hi,

 

I have the same problem but I already have a date table.

 

I linked it to my sales table. The SAMEPERIODLASTYEAR function works properly but the PREVIOUSMONTH function is not working. It's giving me a blank column. Please help !

 

Thank you !

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.