{"id":3858,"date":"2021-12-23T10:46:02","date_gmt":"2021-12-23T18:46:02","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=3858"},"modified":"2021-12-28T20:09:20","modified_gmt":"2021-12-29T04:09:20","slug":"create-a-date-table-with-fiscal-year-starting-on-any-date","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=3858","title":{"rendered":"Create a Date Table with Fiscal Year Starting on Any Date"},"content":{"rendered":"\n<ol class=\"wp-block-list\"><li>Switch to Data view.<a href=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-6-ssm.png#lightbox\"><\/a><\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-6-ssm.png\" alt=\"Screenshot of the data view icon.\"\/><\/figure>\n\n\n\n<p>2. On the&nbsp;<strong>Home<\/strong>&nbsp;ribbon tab, from inside the&nbsp;<strong>Calculations<\/strong>&nbsp;group, click&nbsp;<strong>New Table<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-7-ssm.png\" alt=\"Screenshot of the New table button.\"\/><\/figure>\n\n\n\n<p>3. In the formula bar, enter the following, and then press Enter:<\/p>\n\n\n\n<p>Date =<br>\u200eCALENDARAUTO(6)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-8-ss.png\" alt=\"Screenshot of a new Date formula.\"\/><figcaption>The CALENDARAUTO() function returns a single-column table consisting of date values. The \u201cauto\u201d behavior scans all data model date columns to determine the earliest and latest date values stored in the data model. It then creates one row for each date within this range, extending the range in either direction to ensure full years of data is stored.<br>This function can take a single optional argument which is the last month number of a year. When omitted, the value is 12, meaning that December is the last month of the year. In this case, 6 is entered, meaning that June is the last month of the year.<br><br>Notice the column of date values.<br><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-9-ss.png\" alt=\"Screenshot of the new created Date table.\"><br>If the column does not appear, in the&nbsp;<strong>Fields<\/strong>&nbsp;pane, select a different table, and then select the&nbsp;<strong>Date<\/strong>&nbsp;table.<\/figcaption><\/figure>\n\n\n\n<p>or you may want to use the CALENDAR function.  like <\/p>\n\n\n\n<p>DATE = CALENDAR (DATE (2020,07,01), DATE (2025,06,30))<\/p>\n\n\n\n<p>At the bottom-left corner, in the status bar, notice the table statistics, confirming that 1826 rows of data have been generated, which represents five full years\u2019 data.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-10-ss.png#lightbox\"><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-10-ss.png\" alt=\"Screenshot that shows the Date table has 1826 rows.\"\/><\/a><figcaption>4. On the&nbsp;<strong>Table Tools<\/strong>&nbsp;contextual ribbon, from inside the&nbsp;<strong>Calculations<\/strong>&nbsp;group, click&nbsp;<strong>New Column<\/strong>.<br>In the formula bar, type the following, and then press&nbsp;<strong>Enter<\/strong>:<br><br><code>Year = \"FY\" &amp; YEAR('Date'[Date]) + IF(MONTH('Date'[Date]) &gt; 6, 1)<\/code><br><img decoding=\"async\" src=\"https:\/\/summalai.com\/wp-content\/uploads\/2021\/12\/image-1.png\" alt=\"This image has an empty alt attribute; its file name is image-1.png\"><br><br>A calculated column is created by first entering the column name, followed by the equals symbol (=), followed by a DAX formula that returns a single-value result. The column name cannot already exist in the table.<br>The formula uses the date\u2019s year value but adds one to the year value when the month is after June. This is how fiscal years at Adventure Works are calculated.<br><a href=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-11-ssm.png#lightbox\"><\/a><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-12-ssm.png\" alt=\"Screenshot to verify the new column was added.\"\/><figcaption>Verify that the new column was added.<\/figcaption><\/figure>\n\n\n\n<p>5. Create the following two calculated columns for the&nbsp;<strong>Date<\/strong>&nbsp;table:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Quarter<\/li><li>Month<\/li><\/ul>\n\n\n\n<p>Quarter =<br>&#8216;Date'[Year] &amp; &#8221; Q&#8221;<br>  &amp; IF(<br>    MONTH(&#8216;DATE'[DATE]) &lt;= 3,<br>     3<br>     IF(<br>          MONTH(&#8216;DATE'[DATE]) &lt;= 6,<br>          4<br>          IF(<br>              MONTH(&#8216;DATE'[DATE]) &lt;= 9,<br>             1,<br>             2<br>          )<br>    )<br>)<\/p>\n\n\n\n<p>Month =<br>FORMAT(&#8216;Date'[Date], &#8220;yyyy MMM&#8221;)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-13-ssm.png#lightbox\"><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-13-ssm.png\" alt=\"Screenshot that shows quarter and month columns have been added.\"\/><\/a><\/figure>\n\n\n\n<p>By default, text values sort alphabetically, numbers sort from smallest to largest, and dates sort from earliest to latest.<\/p>\n\n\n\n<p>6. Add the&nbsp;<strong>MonthKey<\/strong>&nbsp;column to the&nbsp;<strong>Date<\/strong>&nbsp;table. This formula computes a numeric value for each year\/month combination.<\/p>\n\n\n\n<p>MonthKey = (YEAR(&#8216;Date'[Date]) * 100) + MONTH(&#8216;Date'[Date])<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"444\" height=\"82\" src=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2021\/12\/image-2.png\" alt=\"\" class=\"wp-image-3860\" srcset=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2021\/12\/image-2.png 444w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2021\/12\/image-2-300x55.png 300w\" sizes=\"(max-width: 444px) 100vw, 444px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-20-ssm.png#lightbox\" alt=\"\"\/><figcaption>In the&nbsp;<strong>Fields<\/strong>&nbsp;pane, ensure that the&nbsp;<strong>Month<\/strong>&nbsp;field is selected (when selected, it will have a dark gray background).<br>7. On the&nbsp;<strong>Column Tools<\/strong>&nbsp;contextual ribbon, from inside the&nbsp;<strong>Sort<\/strong>&nbsp;group, click&nbsp;<strong>Sort by Column<\/strong> and then select&nbsp;<strong>MonthKey<\/strong>.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-21-ssm.png\" alt=\"Screenshot that shows how to use the Sort by column.\"\/><figcaption>8. In the matrix visual, notice that the months are now chronologically sorted.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/media\/lab-6-22-ss.png\" alt=\"Screenshot that proves the months are now sorted correctly.\"\/><\/figure>\n\n\n\n<p>Ref: <a href=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-measures-dax-power-bi\/6-lab\">Lab &#8211; Introduction to DAX in Power BI Desktop &#8211; Learn | Microsoft Docs<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Switch to Data view. 2. On the&nbsp;Home&nbsp;ribbon tab, from inside the&nbsp;Calculations&nbsp;group, click&nbsp;New Table. 3. In the formula bar, enter the following, and then press Enter: Date =\u200eCALENDARAUTO(6) or you may want to use the CALENDAR function. like DATE = CALENDAR (DATE (2020,07,01), DATE (2025,06,30)) At the bottom-left corner, in the status bar, notice the table <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=3858\">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":[1],"tags":[1010,1011],"class_list":["post-3858","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-date-table-with-fiscal-year-starting-on-any-date","tag-sort-month-in-power-bi"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3858","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=3858"}],"version-history":[{"count":4,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3858\/revisions"}],"predecessor-version":[{"id":3882,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/3858\/revisions\/3882"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3858"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3858"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}