{"id":3884,"date":"2021-12-29T17:50:20","date_gmt":"2021-12-30T01:50:20","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=3884"},"modified":"2022-01-17T00:01:13","modified_gmt":"2022-01-17T08:01:13","slug":"how-to-add-a-column-with-fiscal-month-or-fiscal-week-number-not-starting-from-jan-1","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=3884","title":{"rendered":"How to Add a Column with Fiscal Month or Fiscal Week Number Not Starting From Jan 1?"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"> <strong>Part I &#8211; Fiscal Month<\/strong> <\/h3>\n\n\n\n<p>Here is a potential solution assuming you have some kind of data table with a column called Value that has your dates in it:<\/p>\n\n\n\n<p>Create a &#8220;Standard Month&#8221; column using MONTH([Value])<\/p>\n\n\n\n<p>For example, create a &#8220;Custom Month&#8221; column for the Fiscal month starting from April 1:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Custom Month = \n    SWITCH(TRUE(),\n        &#91;Standard Month] >= 4,&#91;Standard Month] - 3,\n        9 + &#91;Standard Month]\n    )\n\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Part II &#8211; Fiscal Week<\/h3>\n\n\n\n<p>Calculating Fiscal Year, Quarter, or Month columns isn\u2019t too difficult in the Date Table in Power BI, but calculating fiscal week becomes slightly tricky. In this post, I\u2019ll share a dynamic solution where you can customize the calculation for week numbers as per your fiscal year.<\/p>\n\n\n\n<p>Let\u2019s dive in!<\/p>\n\n\n\n<p>Since the financial year in India starts in April, I am going to explain this basis the Indian fiscal year but you can customize this to your own fiscal year.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Logic<\/h3>\n\n\n\n<p>Let\u2019s take a look at 1st April 2019 (starting of Indian FY). It\u2019s a Monday (Start of the week). Since the first day of the financial year is a Monday, the 1st week starts from 1st April itself.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.goodly.co.in\/wp-content\/uploads\/2020\/04\/Fiscal-Week-Calculation-in-Power-BI-Apr-2019-Calendar-1.png\" alt=\"Fiscal Week Calculation in Power BI - Apr 2019 Calendar\" class=\"wp-image-10896\"\/><\/figure>\n\n\n\n<p>This logic will change in year 2018 and 2020. Since the first day of the financial year is not a Monday, so the first Monday in April for both these years will be the 2nd week.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.goodly.co.in\/wp-content\/uploads\/2020\/04\/Fiscal-Week-Calculation-in-Power-BI-Apr-2018-Calendar.png\" alt=\"Fiscal Week Calculation in Power BI - Apr 2018 Calendar\" class=\"wp-image-10894\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.goodly.co.in\/wp-content\/uploads\/2020\/04\/Fiscal-Week-Calculation-in-Power-BI-Apr-2020-Calendar.png\" alt=\"Fiscal Week Calculation in Power BI - Apr 2020 Calendar\" class=\"wp-image-10892\"\/><\/figure>\n\n\n\n<p>And the week counting progresses from there on until the end of financial year i.e. 31st Mar.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Financial Week Calculation in Power BI \u2013 Creating a Column in Date Table<\/h3>\n\n\n\n<p>I start with a simple Calendar (or a Date Table)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.goodly.co.in\/wp-content\/uploads\/2020\/04\/Fiscal-Week-Calculation-in-Power-BI-Calendar-Table.png\" alt=\"Fiscal Week Calculation in Power BI - Calendar Table\" class=\"wp-image-10898\"\/><\/figure>\n\n\n\n<p>To add a new column for fiscal week calculation I use the following DAX code.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Fiscal Week =&nbsp;\n--Inputs--\nVAR WeekStartsOn = \"<strong>Mon<\/strong>\"\nVAR FiscalStartMonth = <strong>4<\/strong>\n\n--Calculation--\nVAR FiscalFirstDay = \n  &nbsp; IF(\n  &nbsp; &nbsp; &nbsp; MONTH('Calendar'[Date]) &lt; FiscalStartMonth,\n  &nbsp; &nbsp; &nbsp; DATE(\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YEAR('Calendar'[Date])-1,\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FiscalStartMonth,\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1\n  &nbsp; &nbsp; &nbsp; ),\n  &nbsp; &nbsp; &nbsp; DATE(\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YEAR('Calendar'[Date]),\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FiscalStartMonth,\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1\n  &nbsp; &nbsp; &nbsp; )\n  &nbsp; )\nVAR FilteredTableCount = \n  &nbsp; COUNTROWS(\n  &nbsp; &nbsp; &nbsp; FILTER(\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SELECTCOLUMNS(\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GENERATESERIES(\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FiscalFirstDay,\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Calendar'[Date]\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ),\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \"Dates\",\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Value]\n  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ),\n  &nbsp; &nbsp; &nbsp; FORMAT([Dates],\"ddd\") = WeekStartsOn\n  &nbsp; &nbsp; &nbsp; )\n  &nbsp; )\nVAR WeekNos = \n  &nbsp; IF(\n  &nbsp; &nbsp; &nbsp; FORMAT(FiscalFirstDay,\"ddd\") &lt;&gt; WeekStartsOn,\n  &nbsp; &nbsp; &nbsp; FilteredTableCount + 1,\n  &nbsp; &nbsp; &nbsp; FilteredTableCount\n  &nbsp; )\nRETURN\n&nbsp; &nbsp; \"Week \" &amp; WeekNos<\/pre>\n\n\n\n<p>Note a couple of things<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>I have 2 inputs to make this dynamic \u2013<ul><li><strong>FiscalStartMonth<\/strong>&nbsp;\u2013 Write a number here. Since we in India start in April, hence 4 is my input.<\/li><li><strong>WeekStartsOn<\/strong>&nbsp;\u2013 A 3 letter name of the day. Again we start our week on Mon.&nbsp;<strong>And yes it needs to be 3 letters only.<\/strong><\/li><\/ul><\/li><li>Although the code might look intimidating but the logic is dead simple. All I am doing is counting the number of Mondays that pass by until the current row Date.<\/li><\/ol>\n\n\n\n<p>Use the above code to make a new column in your Date Table and this is how it looks..<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.goodly.co.in\/wp-content\/uploads\/2020\/04\/Fiscal-Week-Calculation-in-Power-BI-Result.png\" alt=\"Fiscal Week Calculation in Power BI - Result\" class=\"wp-image-10902\"\/><\/figure>\n\n\n\n<p>It looks good for year 2020<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>We start with Wed, 1st April 2020 \u2013 as the 1st week<\/li><li>The 1st week continues for 5 days until Sun, 5th April 2020.<\/li><li>And then week 2 begins.<\/li><\/ol>\n\n\n\n<p>Ref: https:\/\/www.goodly.co.in\/calculate-fiscal-week-in-power-bi\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Part I &#8211; Fiscal Month Here is a potential solution assuming you have some kind of data table with a column called Value that has your dates in it: Create a &#8220;Standard Month&#8221; column using MONTH([Value]) For example, create a &#8220;Custom Month&#8221; column for the Fiscal month starting from April 1: Part II &#8211; Fiscal <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=3884\">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":[10,621],"tags":[1063,1017,1018,1062,1019],"class_list":["post-3884","post","type-post","status-publish","format-standard","hentry","category-microsoft","category-power-bi","tag-calculate-fiscal-week-in-power-bi","tag-fiscal-month-or-fiscal-week-number-not-starting-from-jan-1","tag-fiscal-month-starting-from-any-date","tag-fiscal-week-in-power-bi","tag-fiscal-week-starting-from-any-date"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3884","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=3884"}],"version-history":[{"count":3,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3884\/revisions"}],"predecessor-version":[{"id":3940,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3884\/revisions\/3940"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}