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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
priyanath1988
Helper III
Helper III

Calculate Previous year shows Blank

Hi ,

why below code shows Blank for some "Calendar_LastDayOfMonth" value. 

Prior year =  DATEADD('Calendar'[Calendar_LastDayOfMonth], -1, YEAR)
   
priyanath1988_0-1674697448876.png

 

 

How ever it works correct for values

 

priyanath1988_1-1674697526383.png

Is it happening because my Calender table's value starts from 2017? but why it matters? it should calculate the value as expected.

 

Thanks

1 ACCEPTED SOLUTION

You are welcome.  Ensure that the calendar goes one year prior from the first date.  Replace previousmonth with previousyear. 


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

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Please how do i fix the below error message when try to load data?

'Failed to save modifications to the server. Error returned: 'OLE DB or ODBC error: [Expression.Error] The key didn't match any rows in the table.. '.

@Anonymous , Could you please post your question in a new thread? Tis way you will get correct response sooner. My post is around the previous month/ year calculation.

 

Thanks.

Priya

Ashish_Mathur
Super User
Super User

Hi,

Yes, it is because your Calendar table starts from 2017.


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

@Ashish_Mathur , Thanks for your response.

In that case why Blank is coming for Prior month for below example

priyanath1988_0-1674715582044.png

Prior Month = DATEADD('Calendar'[Calendar_LastDayOfMonth], -1, MONTH)
   Thanks,
Priya

Does this measure work

=calculate(min('Calendar'[Calendar_LastDayOfMonth]),previousmonth('Calendar'[Calendar_LastDayOfMonth]))


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

@Ashish_Mathur , yes this works. Thank you so much.

Could you please suggest solution for the previous year so that it does not show Blank?

Thanks,

Priya

You are welcome.  Ensure that the calendar goes one year prior from the first date.  Replace previousmonth with previousyear. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Super User
Super User

@priyanath1988 You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

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



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler , Thank you for your response. I tried one of your codes but it throws an error. Could you please suggest whats wrong in it?

priyanath1988_0-1674702838074.png

 

Thanks

Priya

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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