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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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
Ozelle
New Member

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.. '.

@Ozelle , 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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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