{"id":3945,"date":"2022-01-24T09:51:13","date_gmt":"2022-01-24T17:51:13","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=3945"},"modified":"2022-01-24T09:51:15","modified_gmt":"2022-01-24T17:51:15","slug":"how-to-create-a-calculate-column-for-the-same-day-of-last-year","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=3945","title":{"rendered":"How to Create a Calculate Column for The Same Day of Last Year"},"content":{"rendered":"\n<p>You can create a calculated column in Calendar Dimension:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SameDayLY= \nvar TodayDate = TODAY()\nvar LastYear = YEAR(TodayDate)-1\nvar LastMonth = MONTH(TodayDate)\nvar LastDay = DAY(TodayDate)\nreturn\n'Calendar'[Date]= DATE(LastYear,LastMonth,LastDay)\n\nThis solution shoule be good for most of the situation.\n\nHowever, your way returned a true value for \"2019-03-01\" if Today date was a Leap day for example \"2020-02-29\" but that was a wrong behavior according to some business requirements so you could handle this as follow:\n\nSameDayLY =\nvar TodayDate = TODAY() \/\/ \"2020-02-29\"\nvar TodayYear = YEAR(TodayDate)\nvar LastYear = YEAR(TodayDate)-1\nvar LastMonth = MONTH(TodayDate)\nvar LastDay = DAY(TodayDate)\nreturn\nIF ( MOD(TodayYear,4) = 0 &amp;&amp; LastMonth = 2 &amp;&amp; LastDay =29 , FALSE() , 'Calendar'[Date]= DATE(LastYear,LastMonth,LastDay))<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can create a calculated column in Calendar Dimension: SameDayLY= var TodayDate = TODAY() var LastYear = YEAR(TodayDate)-1 var LastMonth = MONTH(TodayDate) var LastDay = DAY(TodayDate) return &#8216;Calendar'[Date]= DATE(LastYear,LastMonth,LastDay) This solution shoule be good for most of the situation. However, your way returned a true value for &#8220;2019-03-01&#8221; if Today date was a Leap day <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=3945\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[621],"tags":[1064],"class_list":["post-3945","post","type-post","status-publish","format-standard","hentry","category-power-bi","tag-the-same-day-of-last-year"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3945"}],"version-history":[{"count":1,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3945\/revisions"}],"predecessor-version":[{"id":3946,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3945\/revisions\/3946"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3945"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3945"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}