cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Anonymous
Not applicable

Previous month value

Hi!

I think I'm going crazy... I made this simple value to calculate the value of last month but the output is BLANK.... What's wrong?

 

CalcRevenuePrevious = CALCULATE(SUM('table'[Revenue]); PREVIOUSMONTH('table'[YearMonthDate]))

1 ACCEPTED SOLUTION
GilbertQ
Super User
Super User

Hi @Anonymous

 

Do you have a Date Table in your Data model?

 

For the PREVIOUSMONTH measure to work, you would require having a date table for the Time Intelligence to work correctly.

 

Here is a link below to create a Date table, after which you can then create a relationship to your 'table'[YearMonthDate]

 

https://www.fourmoo.com/2016/09/13/power-bi-how-to-easily-create-dynamic-date-tabledimension-with-fiscal-attributes-using-power-query/





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

Proud to be a Super User!







Power BI Blog

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Can't tell you what is wrong without sample data to recreate. But, note the description of PREVIOUSMONTH from the documentation:

 

Returns a table that contains a column of all dates from the previous month, based on the first date in the dates column, in the current context.

 

From:

https://msdn.microsoft.com/en-us/library/ee634758.aspx

 

So, the first question would be are you sure that the first date in that table in the current context is really the month you want?

 

 


@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

PREVIOUSMONTH('table'[YearMonthDate]) alone returns the value I want. My table is aggregated on user-month level with the first date of that month in this column. 

Since this part of the formula works, I don't understand why the whole formula doesn't want to return a value. 

Going to need to see some sample data to recreate, but I would go with @GilbertQ suggestion of a date table.


@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
GilbertQ
Super User
Super User

Hi @Anonymous

 

Do you have a Date Table in your Data model?

 

For the PREVIOUSMONTH measure to work, you would require having a date table for the Time Intelligence to work correctly.

 

Here is a link below to create a Date table, after which you can then create a relationship to your 'table'[YearMonthDate]

 

https://www.fourmoo.com/2016/09/13/power-bi-how-to-easily-create-dynamic-date-tabledimension-with-fiscal-attributes-using-power-query/





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

Proud to be a Super User!







Power BI Blog

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors