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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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