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
PeraZo
Helper I
Helper I

Power BI Previous Month Column showing blank

Hello, Power BI Community

 

I have a Data set like below.

 

Previousmonth.png

 

I want to show Previous month value for each state (In this case WA and NY) so I wrote below DAX.

 

Previousmonth =
CALCULATE(SUM('Sheet1'[Sale]),PREVIOUSMONTH('Sheet1'[YearMonth]))
 
But the result is showing blank...
 
Could someone please help me understand how I can make this possible?
1 ACCEPTED SOLUTION
jpessoa8
Continued Contributor
Continued Contributor

Hi @PeraZo ,

 

The usage of PREVIOUSMONTH requires the Filter context and, for that reason should be used in a measure instead of a calculated column.

 

If, do to some business logic, you really need to create a calculated column for this, you should do:

var PreviousDate = IF( MONTH('Sheet1'[YearMonth]) = 1 , 
                        //if the previous month is last year
                        DATE(YEAR('Sheet1'[YearMonth])-1,MONTH('Sheet1'[YearMonth])-1,1), 
                        //if the previous month is this year
                        DATE(YEAR('Sheet1'[YearMonth]),MONTH('Sheet1'[YearMonth])-1,1)
                    )
return CALCULATE(SUM('Sheet1'[Sale]),FILTER('Sheet1', 'Sheet1'[YearMonth] = PreviousDate))

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudo 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Jorge Pessoa

View solution in original post

4 REPLIES 4
Ahmedx
Super User
Super User

or try this

Screenshot_6.png

Ahmedx
Super User
Super User

pls try this

Screenshot_4.png

Ashish_Mathur
Super User
Super User

Hi,

You should first of all create a Date Table with calculated column formulas for Year, Month name and Month number.  Sort the Month name by the Month number.  Write your formula as a measure (not as a calculated colummn).  Furthermore, revise that measure to:

Previousmonth = CALCULATE(SUM('Sheet1'[Sale]),PREVIOUSMONTH(Calendar[Date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
jpessoa8
Continued Contributor
Continued Contributor

Hi @PeraZo ,

 

The usage of PREVIOUSMONTH requires the Filter context and, for that reason should be used in a measure instead of a calculated column.

 

If, do to some business logic, you really need to create a calculated column for this, you should do:

var PreviousDate = IF( MONTH('Sheet1'[YearMonth]) = 1 , 
                        //if the previous month is last year
                        DATE(YEAR('Sheet1'[YearMonth])-1,MONTH('Sheet1'[YearMonth])-1,1), 
                        //if the previous month is this year
                        DATE(YEAR('Sheet1'[YearMonth]),MONTH('Sheet1'[YearMonth])-1,1)
                    )
return CALCULATE(SUM('Sheet1'[Sale]),FILTER('Sheet1', 'Sheet1'[YearMonth] = PreviousDate))

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudo 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Jorge Pessoa

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.