<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>SelfServedBI.com</title>
    <description>Business intelligence and analytics for the everyday analyst</description>
    <link>https://selfservedbi.com/</link>
    <atom:link href="https://selfservedbi.com/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>Power BI Datamarts First Impressions</title>
        <description>&lt;p&gt;Last week at &lt;a href=&quot;https://mybuild.microsoft.com/en-US/sessions/880c2556-1f8e-4e4c-89ac-77c4149cdf93?source=/schedule&quot;&gt;Microsoft Build&lt;/a&gt; the Power BI team announced Datamarts for Power BI. (&lt;a href=&quot;https://powerbi.microsoft.com/en-us/blog/announcing-public-preview-of-datamart-in-power-bi/&quot;&gt;Main blog post&lt;/a&gt;, &lt;a href=&quot;https://youtu.be/QxrUJCbcGy4&quot;&gt;Mechanics demo video&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;After spending some of my weekend playing with these features I thought I would share my first impressions.&lt;/p&gt;

&lt;h3 id=&quot;what-has-been-released&quot;&gt;What has been released?&lt;/h3&gt;

&lt;p&gt;In summary:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;A special &lt;a href=&quot;https://docs.microsoft.com/en-us/power-bi/transform-model/dataflows/dataflows-introduction-self-service&quot;&gt;dataflow&lt;/a&gt; that deposits data into an…&lt;/li&gt;
  &lt;li&gt;automatically provisioned &lt;a href=&quot;https://azure.microsoft.com/en-us/products/azure-sql/database/&quot;&gt;Azure SQL database&lt;/a&gt;…&lt;/li&gt;
  &lt;li&gt;which is then used as the data source for an automatically created &lt;a href=&quot;https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-use-directquery&quot;&gt;DirectQuery&lt;/a&gt; dataset.&lt;/li&gt;
  &lt;li&gt;All the above is editable via a single web UI and treated as one package.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;how-does-it-work&quot;&gt;How does it work?&lt;/h3&gt;

&lt;p&gt;When you log onto &lt;a href=&quot;http://app.powerbi.com&quot;&gt;app.powerbi.com&lt;/a&gt; and go into a premium workspace (premium capacity or per user), you’ll see the ability to create a new Datamart.&lt;/p&gt;

&lt;figure&gt;
&lt;img src=&quot;/attachments/screenshot_20220529-220243_edge.jpg&quot; width=&quot;250&quot; /&gt;
&lt;figcaption&gt;&lt;em&gt;Screenshot of creating a new Datamart in a premium capacity workspace.&lt;/em&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;This will open a new web experience where you then need to create a special kind of Power Query dataflow, except this time your dataflow will deposit the data into an automatically provisioned &lt;a href=&quot;https://azure.microsoft.com/en-us/products/azure-sql/database/&quot;&gt;Azure SQL database&lt;/a&gt; (an &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/azure-sql/database/elastic-pool-overview?view=azuresql&quot;&gt;elastic&lt;/a&gt; &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/azure-sql/database/service-tier-general-purpose?view=azuresql&quot;&gt;general purpose&lt;/a&gt; database). Also, your dataflow will only be editable within the new Datamart UI and will not be treated as a regular dataflow… Except that it very much &lt;em&gt;looks&lt;/em&gt; like a regular dataflow but now it deposits the data into an Azure SQL database instead of a datalake (&lt;a href=&quot;https://docs.microsoft.com/en-us/common-data-model/model-json&quot;&gt;CDM format&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;On top of this, a read-only (and “locked down”) &lt;a href=&quot;https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-use-directquery&quot;&gt;DirectQuery&lt;/a&gt; dataset will be automatically provisioned that is based on the data inside the Azure SQL database. It is locked into sharing the same name as the Datamart. The dataset can also only be edited via the Datamart web UI (you cannot connect to the Datamart’s auto-DQ dataset via external tools such as &lt;a href=&quot;https://tabulareditor.com/&quot;&gt;Tabular Editor&lt;/a&gt; or &lt;a href=&quot;https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver16&quot;&gt;SQL Server Management Studio&lt;/a&gt; for editing).&lt;/p&gt;

&lt;p&gt;The reason for the locked down approach is likely because from the Datamart web UI you can create roles that in turn will create roles for both the auto-DQ dataset as well as database roles on the Azure SQL DB.&lt;/p&gt;

&lt;p&gt;Measures and relationships are also able to be created in the web UI, which reminds me almost of the &lt;a href=&quot;https://azure.microsoft.com/en-us/blog/introducing-the-azure-analysis-services-web-designer/?cdn=disable&quot;&gt;Azure Analysis Services Web designer&lt;/a&gt; UI before it got &lt;a href=&quot;https://azure.microsoft.com/en-us/updates/azure-analysis-services-web-designer-to-be-discontinued/?cdn=disable&quot;&gt;shut down&lt;/a&gt;.&lt;br /&gt;
On top of that, there’s also a simple interface for running SQL queries and “visual” queries against the database.&lt;/p&gt;

&lt;figure&gt;
&lt;img src=&quot;/attachments/screenshot_20220529-221146_edge.jpg&quot; width=&quot;500&quot; /&gt;
&lt;figcaption&gt;&lt;em&gt;Example row level security dialog.&lt;/em&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;so-why-are-power-bi-datamarts-such-a-big-deal&quot;&gt;So why are Power BI Datamarts such a big deal?&lt;/h3&gt;

&lt;p&gt;The big draw card in all of this is really the creation and automatic provision of Azure SQL databases, as well as being able to easily load them from Power Query.&lt;/p&gt;

&lt;p&gt;The other items (in my opinion) are nice to have but are also use-case specific:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The web UI for data modelling is nice for lowering the barrier for newcomers but I’m unlikely to use it (creating measures and managing the data model will always be more efficient in Tabular Editor).&lt;/li&gt;
  &lt;li&gt;The auto-DQ dataset is interesting, but it steers people away from import mode and taking full advantage of the incredible &lt;a href=&quot;https://www.microsoftpressstore.com/articles/article.aspx?p=2449192&quot;&gt;Vertipaq engine&lt;/a&gt;, probably Power BI’s strongest selling point.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;why-is-being-able-to-create-and-load-data-into-an-azure-sql-db-so-hyped&quot;&gt;Why is being able to create and load data into an Azure SQL DB so hyped?&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;It let’s you seperate the query logic layer from the data model layer.&lt;/li&gt;
  &lt;li&gt;It allows for other tools to analyze the data besides Power BI (e.g. any tool that uses SQL)&lt;/li&gt;
  &lt;li&gt;It gives you a good place to store additional / infrequent information, such as budgets, forecasts, and other supplemental data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But above all, it cuts through several barriers that users face when they want to set up a reporting solution. Instead of having to get access to an &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/active-directory-how-subscriptions-associated-directory&quot;&gt;Azure subscription&lt;/a&gt; to set up an &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/data-factory/&quot;&gt;Azure Data Factory&lt;/a&gt; resource and Azure SQL DB resource, you can now just do it with the click of a button. &lt;strong&gt;For business users trying to come up with robust, supportable solutions, this is an absolute godsend&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For internal IT departments it may seem daunting that users are creating their own Azure SQL databases, but in most cases this may be being done anyway by more advanced users, either through local SQL installs at the Business unit level, Access databases, inefficient SharePoint lists, or a network of Excel files as “databases”.&lt;/p&gt;

&lt;p&gt;IT departments should keep an eye on overall deployments, resource consumption, and data sensitivity, but for the most part this change is just another in a long process of IT departments transitioning away from being &lt;strong&gt;&lt;em&gt;data gatekeepers&lt;/em&gt;&lt;/strong&gt; towards being &lt;strong&gt;&lt;em&gt;data gardeners&lt;/em&gt;&lt;/strong&gt; (by helping the business “grow” their analytics capabilities).&lt;/p&gt;

&lt;h3 id=&quot;why-is-loading-from-a-dataflow-into-an-azure-sql-db-better-than-into-a-datalake&quot;&gt;Why is loading from a dataflow into an Azure SQL DB better than into a datalake?&lt;/h3&gt;

&lt;p&gt;Both contain type information, both load quickly, both can be connected to via Power BI Desktop, however there are some differences:&lt;/p&gt;

&lt;p&gt;Loading a dataflow into their standard datalake is much “cheaper” storage as it’s just blob storage (CSVs + some json metadata files).&lt;/p&gt;

&lt;p&gt;Loading a dataflow into an Azure SQL DB allows you to assign roles and row level security, as well as allows for simple connections from a variety of tools, (Tabular Editor provider datasource, SSMS, Python, and anything else that can connect to a SQL database).&lt;/p&gt;

&lt;h3 id=&quot;rough-edges-and-improvements-to-be-made&quot;&gt;Rough Edges and improvements to be made&lt;/h3&gt;

&lt;p&gt;With all the benefits so far about this new package of features, there are still some improvements that could be made:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;It is very much a &lt;strong&gt;package&lt;/strong&gt; of features. If you didn’t want your DirectQuery dataset, too bad you’ve now got one. Don’t want to use the web UI and would rather use Tabular Editor? Not possible.&lt;/li&gt;
  &lt;li&gt;When first creating the Datamart you don’t input a name, instead it gets given an autogenerated name that then needs to be renamed afterwards.&lt;/li&gt;
  &lt;li&gt;When you go to create a dataflow it asks if instead you would like to create a Datamart, when they’re not really synonymous. Instead it would make more sense that when you make a dataflow you can choose whether to load the data into a datalake or into a database. &lt;a href=&quot;https://ideas.powerbi.com/ideas/idea/?ideaid=af9c4467-22df-ec11-b5cf-281878a5ed2b&quot;&gt;Support this idea here&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;People have reported different experiences, but trying to build an “import” dataset off of the Azure SQL DB was not workable for me. The main issue I ran into no matter what method I used was that the Azure SQL DB appeared to &lt;a href=&quot;https://www.google.com/amp/s/blog.sqlauthority.com/2016/03/18/sql-server-introduction-sql-azure-database-throttling/%3famp&quot;&gt;throttle my queries&lt;/a&gt; &lt;strong&gt;hard&lt;/strong&gt;. Very occasionally I could load a 200k row table, but most times it would stall at 50k and then time out after several hours. To me this is an absolute deal breaker and removes an incentive to use the feature, so hopefully as Datamarts goes through preview these kinds of issues get ironed out.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;final-thoughts&quot;&gt;Final thoughts&lt;/h1&gt;

&lt;p&gt;I look forward to when the Azure SQL DB can handle me querying all of its data into my import model. Once this is possible it will be an absolute game changer.&lt;/p&gt;

&lt;p&gt;I’m not convinced about the forcing of DirectQuery onto us or the requirements to use the web UI. Hopefully this will get removed and split out.&lt;/p&gt;

&lt;p&gt;The story of dataflows, Datamarts, and people comparing them is confusing. To simplify this story I really think the Power BI team should position dataflows as a tool to transfer data from source systems into a storage destination (whether that be datalake storage or relational database storage).&lt;/p&gt;

&lt;div align=&quot;center&quot;&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;Allowing dataflows to choose their destination simplifies the story for users:&lt;br /&gt;- a dataflow is a way to get data from source systems into a storage destination&lt;br /&gt;- you can pick either basic datalake storage (CSVs+manifest/typing) or richer relational database storage (Azure SQL DB)&lt;/p&gt;&amp;mdash; James Fancke (@jdfancke) &lt;a href=&quot;https://twitter.com/jdfancke/status/1530825708607619073?ref_src=twsrc%5Etfw&quot;&gt;May 29, 2022&lt;/a&gt;&lt;/blockquote&gt; &lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;&lt;/div&gt;

&lt;p&gt;Finally, I read a decent &lt;a href=&quot;https://datamonkeysite.com/2022/05/25/first-look-at-datamart/&quot;&gt;blog post by Mim&lt;/a&gt; that also has more specific detail behind Datamarts and recommend giving it a read.&lt;/p&gt;
</description>
        <pubDate>Mon, 30 May 2022 05:32:39 +0000</pubDate>
        <link>https://selfservedbi.com/2022/05/30/power-bi-datamarts-first-impressions/</link>
        <guid isPermaLink="true">https://selfservedbi.com/2022/05/30/power-bi-datamarts-first-impressions/</guid>
      </item>
    
      <item>
        <title>Introduction to hierarchies in Analysis Services and Power BI</title>
        <description>&lt;p&gt;A &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Hierarchy&quot;&gt;hierarchy&lt;/a&gt; is a concept where related items are represented as being above, below, or at the same level as each other.&lt;/p&gt;

&lt;p&gt;Some examples of hierarchies include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Organisation charts&lt;/strong&gt; with different levels of managers and employees;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Calendars&lt;/strong&gt; with dates organized in years, months, and days;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Products&lt;/strong&gt; arranged into different classes, groups, or brands; and&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Bills of material&lt;/strong&gt; grouped into sub assemblies, kits, and components.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these hierarchies include “parent” members and “child” members beneath them, and serve as a way of organizing information into different levels.&lt;/p&gt;

&lt;h3 id=&quot;how-hierarchies-are-implemented-in-analysis-services&quot;&gt;How hierarchies are implemented in Analysis Services&lt;/h3&gt;

&lt;p&gt;In the context of data modelling, each item in the above examples is an attribute (i.e. column) within a table.&lt;/p&gt;

&lt;p&gt;It follows that &lt;a href=&quot;https://docs.microsoft.com/en-us/sql/analysis-services/tabular-models/hierarchies-ssas-tabular?view=sql-server-2017&quot;&gt;Analysis Services and Power BI use hierarchies&lt;/a&gt; as a way to relate different &lt;strong&gt;columns&lt;/strong&gt; to each other, with each column on a different level to the others. &lt;em&gt;Note that this is different to relating tables, which is handled separately by the Relationship object.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The specific definition used in the Analysis Services Tabular Protocol is:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Hierarchy&lt;/strong&gt;: A logical tree structure that organizes a record such that each member has one parent member and zero or more child members.&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;—&lt;/em&gt; &lt;em&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/mt719260(v=sql.105).aspx&quot;&gt;Analysis Services Tabular Protocol&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To get a better understanding of the components that make up a hierarchy, I think it’s worth exploring the Hierarchy object’s location within the Tabular Object Model of Analysis Services and the properties it has.&lt;/p&gt;

&lt;h4 id=&quot;hierarchy-object-model-location&quot;&gt;Hierarchy Object Model Location&lt;/h4&gt;

&lt;p&gt;Below is the current metadata hierarchy of the Hierarchy object within the Tabular Object Model (TOM).&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/ssas-hierarchy-metadata-location.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;Location of the Hierarchy object within the Tabular Object Model, from the Analysis Services Tabular Protocol.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;&lt;em&gt;I’ll have to be careful not to write myself into knots when referencing the hierarchy of the Hierarchy object.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Note that the Hierarchy object is a child object to the Table object, meaning it will inherit properties such as the table location.&lt;/p&gt;

&lt;p&gt;You can also see that the Hierarchy object contains the Level object for each of its hierarchy levels.&lt;/p&gt;

&lt;h4 id=&quot;hierarchy-object-properties&quot;&gt;Hierarchy object properties&lt;/h4&gt;

&lt;p&gt;Within the Hierarchy object there are the following properties:&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/ssas-hierarchy-metadata-properties.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;Hierarchy object properties.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;I’d like to call out a few of the above properties:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;TableID&lt;/strong&gt; - the hierarchy will belong to a specific table.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Name/Description&lt;/strong&gt; - the hierarchy can have its own name and description separate to that of the table.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;IsHidden&lt;/strong&gt; - it can be hidden if needed.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;DisplayFolder&lt;/strong&gt; - it can be organized into its own display folder like any other column or measure.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;HideMembers&lt;/strong&gt; - it can have a property that gets read by Excel (as of January 2019 Power BI does not respect this property) in which blank members are hidden. &lt;em&gt;More on this later.&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;hierarchy-level-object-properties&quot;&gt;Hierarchy Level Object Properties&lt;/h4&gt;

&lt;p&gt;Underneath the Hierarchy object is the Level object. Below are the properties of each of the hierarchy levels:&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/ssas-hierarchy-level-metadata-properties.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;Hierarchy Level object properties.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;To highlight some of the properties:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;ColumnID&lt;/strong&gt; - this is the column that the hierarchy level is based on. It is a pointer to the column and does &lt;strong&gt;not&lt;/strong&gt; create a copy of the column’s data. &lt;strong&gt;Important&lt;/strong&gt;: There is no concept of a ParentColumn-ChildColumn structure. Instead there must be one column per level.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Name&lt;/strong&gt; - despite referencing another column, the level can have its own name separate to that of the column it references.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;HierarchyID&lt;/strong&gt; - this links the level back to the hierarchy it belongs to.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Ordinal&lt;/strong&gt; - this is a 0-based index that shows where to place the level relative to other levels within the hierarchy, with 0 being the top level.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;the-purpose-of-hierarchies&quot;&gt;The purpose of hierarchies&lt;/h3&gt;

&lt;p&gt;Now that we know the basic structure of how hierarchies are implemented, let’s explore why you’d want to use them.&lt;/p&gt;

&lt;p&gt;The best explanation I’ve read is from Marco Russo and Alberto Ferrari’s book:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;You can think of them [hierarchies] as predefined pathways through your data that help your users explore down from one level of granularity to another in a meaningful way.&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;— p. 190,&lt;/em&gt; &lt;em&gt;&lt;a href=&quot;https://www.microsoftpressstore.com/store/tabular-modeling-in-microsoft-sql-server-analysis-services-9781509302772&quot;&gt;Tabular Modelling in Microsoft SQL Server Analysis Services, 2nd Edition&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In other words, hierarchies provide intuition on how different columns relate to each other and provide a guide for how you may want to structure your Pivot Tables and other visualizations.&lt;/p&gt;

&lt;p&gt;Other advantages to using hierarchies include only needing to add one item (the hierarchy) to your report instead of many, meaning that report building could be quicker for new users. Note that in Excel the entire hierarchy must be used within a field, whereas Power BI allows you to use individual levels from a hierarchy.&lt;/p&gt;

&lt;p&gt;Because each level can be renamed, you’re also able to have different names for the same columns if they mean different things to different departments. However, I’d caution against this as it can easily cause confusion. A much better solution is to get everyone using the same terms for the same data.&lt;/p&gt;

&lt;p&gt;Finally, hierarchies (beginning in SQL Server 2017 / 1400 level compatibility) allow you to implement ragged hierarchies.&lt;/p&gt;

&lt;h3 id=&quot;different-kinds-of-hierarchies&quot;&gt;Different kinds of hierarchies&lt;/h3&gt;

&lt;p&gt;Now that I’ve mentioned “ragged hierarchies”, it’s probably best to start explaining the different kinds of hierarchies that you might encounter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ragged hierarchies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A ragged hierarchy is a hierarchy where not all items have children objects down to the lowest level.&lt;/p&gt;

&lt;p&gt;Patrick Leblanc has a great video explaining this topic (below), but essentially a ragged hierarchy is one where there are blanks in your hierarchy, and that your blank members only have blank child members.&lt;/p&gt;

&lt;div align=&quot;center&quot;&gt;&lt;iframe class=&quot;frame-pardot&quot; width=&quot;100%&quot; height=&quot;100%&quot; src=&quot;https://www.youtube-nocookie.com/embed/4Km6HmydY7A&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;

&lt;p&gt;Ragged hierarchies are supported in 1400 compatibility level models, and possible in Power BI Analyze in Excel, but &lt;a href=&quot;https://community.powerbi.com/t5/Issues/Hierarchy-blanks-issue/idi-p/221123&quot;&gt;not yet officially supported (as of January 2019) by Power BI visuals&lt;/a&gt; (they ignore the HideMembers property). See the &lt;a href=&quot;https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/14511612-ragged-or-parent-child-hierarchy-visuals&quot;&gt;feature request here&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;Here is how you can add ragged hierarchies to a published &lt;a href=&quot;https://twitter.com/hashtag/PowerBI?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#PowerBI&lt;/a&gt; model for Analyze in Excel using &lt;a href=&quot;https://twitter.com/hashtag/TabularEditor?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#TabularEditor&lt;/a&gt;. &lt;br /&gt;I hope that some day Power BI Desktop will allow you to edit this property (and that PBI visuals will respect it!) &lt;a href=&quot;https://t.co/8YWTkM0ICV&quot;&gt;pic.twitter.com/8YWTkM0ICV&lt;/a&gt;&lt;/p&gt;&amp;mdash; James Fancke (@jdfancke) &lt;a href=&quot;https://twitter.com/jdfancke/status/1081195563247235074?ref_src=twsrc%5Etfw&quot;&gt;January 4, 2019&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;Christian Wade has commented that they are currently working on implementing ragged hierarchies into Power BI.&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;We want to get this working in Power BI. Starting with consumption, then authoring. It doesn&amp;#39;t work the same as HideMemberIf in MD&lt;/p&gt;&amp;mdash; Christian Wade (@_christianWade) &lt;a href=&quot;https://twitter.com/_christianWade/status/1081407315624906752?ref_src=twsrc%5Etfw&quot;&gt;January 5, 2019&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;&lt;strong&gt;Natural vs Unnatural hierarchies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Natural hierarchies are where all identical values within a hierarchy column all have the same parent value. An example of this is where each product SKU belongs to a brand. There are no cases where the same product SKU value belongs to different brands.&lt;/p&gt;

&lt;p&gt;An unnatural hierarchy is one where the same value in a hierarchy level has different parent levels. An example of this is where the value “January” can belong to multiple years.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attribute hierarchies vs user defined hierarchies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Analysis Services Tabular Protocol defines an &lt;strong&gt;attribute hierarchy&lt;/strong&gt; as per below:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Attribute hierarchy:&lt;/strong&gt; An implied single-level hierarchy, based on a single attribute, that consists of all the members of the attribute. An all-level member can optionally be enabled for an attribute hierarchy.&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;—&lt;/em&gt; &lt;em&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/mt719260(v=sql.105).aspx&quot;&gt;Analysis Services Tabular Protocol&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What this effectively means is that in Analysis Services Tabular, each attribute (i.e. column) has an attribute hierarchy automatically generated for itself. These attribute hierarchies are what you descend when you use MDX formulas (and when you’re using Excel cube formulas). &lt;em&gt;More information on attribute hierarchies can be found&lt;/em&gt; &lt;em&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/sql/analysis-services/multidimensional-models-olap-logical-dimension-objects/attributes-and-attribute-hierarchies?view=sql-server-2017&quot;&gt;here&lt;/a&gt;&lt;/em&gt; &lt;em&gt;and&lt;/em&gt; &lt;em&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/sql/analysis-services/lesson-4-4-hiding-and-disabling-attribute-hierarchies?view=sql-server-2017&quot;&gt;here&lt;/a&gt;&lt;/em&gt; &lt;em&gt;(applies to Analysis Services Multidimensional).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Because there is virtually no control over attribute hierarchies in Analysis Services Tabular, this post is focused solely on user defined hierarchies.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;user defined hierarchy&lt;/strong&gt; is what you, the data modeller, are able to develop in Analysis Services Tabular and Power BI, and is exposed as a hierarchy that can be dropped into Excel PivotTables and Power BI visuals.&lt;/p&gt;

&lt;h3 id=&quot;closing-remarks&quot;&gt;Closing remarks&lt;/h3&gt;

&lt;p&gt;The aim of this post was to provide an introduction to the theory of hierarchies.&lt;/p&gt;

&lt;p&gt;In my next post I’ll be putting this theory to practice with how you’ll want to prepare your data for a hierarchy, how you can create hierarchies objects using SSDT and Tabular Editor, and some practical hierarchy use cases.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Feel free to leave any comments or corrections below.&lt;/em&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 08 Jan 2019 07:16:53 +0000</pubDate>
        <link>https://selfservedbi.com/2019/01/08/hierarchies-1-introduction-to-hierarchies-in-analysis-services-and-power-bi/</link>
        <guid isPermaLink="true">https://selfservedbi.com/2019/01/08/hierarchies-1-introduction-to-hierarchies-in-analysis-services-and-power-bi/</guid>
      </item>
    
      <item>
        <title>KPIs #2: Developing KPIs in Power BI and Analysis Services using Tabular Editor</title>
        <description>&lt;p&gt;KPIs, or Key Performance Indicators, are a common way to gauge performance against a set of objectives, and are an integral part of performance management.&lt;/p&gt;

&lt;p&gt;Without getting too deep in jargon, the fundamental idea behind a KPI is that you are comparing some known measure against a target, and then grading the comparison.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is a follow up to&lt;/em&gt; &lt;em&gt;&lt;a href=&quot;/2018/12/28/kpis-and-their-usage-in-analysis-services-excel-power-pivot-and-power-bi-%f0%9f%9a%a6/&quot;&gt;my post exploring KPIs within Analysis Services&lt;/a&gt;. You may want to read that post first as it provides an introduction to KPIs.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I received some feedback from Daniel Otykier &lt;em&gt;(author of&lt;/em&gt; &lt;em&gt;&lt;a href=&quot;https://tabulareditor.github.io/&quot;&gt;Tabular Editor&lt;/a&gt;)&lt;/em&gt; regarding my last post and it inspired me to dive deeper into how KPIs are handled within Analysis Services, how you can create them using Tabular Editor, as well as their implementation within Power BI.&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;Great post. I noticed that you can reference any KPI expressions elsewhere in your model, just as if they were another measure: [_Sales Goal], [_Sales Status] and [_Sales Trend] if the base measure is named [Sales]. Also &lt;a href=&quot;https://twitter.com/hashtag/TabularEditor?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#TabularEditor&lt;/a&gt; is great for editing KPIs as well :-)&lt;/p&gt;&amp;mdash; Daniel Otykier (@DOtykier) &lt;a href=&quot;https://twitter.com/DOtykier/status/1078652533911052288?ref_src=twsrc%5Etfw&quot;&gt;December 28, 2018&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;Without wasting any time, below are my observations after a further look into KPIs.&lt;/p&gt;

&lt;h2 id=&quot;observation-1-kpis-create-hidden-measures-that-are-able-to-be-referenced-in-other-dax-expressions&quot;&gt;Observation 1: KPIs create “hidden” measures that are able to be referenced in other DAX expressions&lt;/h2&gt;

&lt;p&gt;Daniel is completely correct in his reply to my tweet above, you can reference the automatically generated hidden measures related to your KPI in other parts of your model as if they were regular measures. They are in the form of [_MeasureName Goal], [_MeasureName Status] and [_MeasureName Trend], just as Daniel described.&lt;/p&gt;

&lt;p&gt;Interestingly, &lt;a href=&quot;http://daxstudio.org/&quot;&gt;DAX Studio&lt;/a&gt; currently doesn’t organize the [_MeasureName Trend] measure in the same way as the others with their shortform names (e.g. “Value”, “Goal”, and “Status”).&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/DAX-Studio-KPI-Trend-Query.png&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;DAX Studio querying KPI trend and status.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;Note that in SSDT the “hidden” KPI measures will appear with a red squiggly line underneath them, indicating that SSDT does not recognize the measures, however, they should still evaluate correctly.&lt;/p&gt;

&lt;h2 id=&quot;observation-2-statusexpression-and-trendexpression-can-both-be-created-in-tabular-editor-and-they-should-evaluate-to-a-number-corresponding-with-their-statusgraphic-and-trendgraphic&quot;&gt;Observation 2: StatusExpression and TrendExpression can both be created in Tabular Editor and they should evaluate to a number corresponding with their StatusGraphic and TrendGraphic&lt;/h2&gt;

&lt;p&gt;Currently when developing KPIs in SSDT the StatusExpression is created automatically when you use the KPI dialog. Note, you are not able to create a TrendExpression through the SSDT KPI dialog and there are no hints that the property even exists.&lt;/p&gt;

&lt;p&gt;On the other hand, creating the StatusExpression and TrendExpression is possible in Tabular Editor for both Analysis Services Tabular &lt;strong&gt;and&lt;/strong&gt; Power BI data models. _You might be able to create a TrendExpression for a Power Pivot model within Excel, however you can’t connect to it within Tabular Editor so I haven’t looked any furthe_r.&lt;/p&gt;

&lt;p&gt;Because you are able to edit the expressions in Tabular Editor, you can create them in whichever form you’d like, although they should always evaluate to either [-2, -1, 0, 1, 2] for a 5 icon set, or [-1, 0, 1] for a 3 icon set for Power BI.&lt;/p&gt;

&lt;p&gt;Below is an example for how you might accomplish a TrendExpression for your sales vs prior period sales. You can also achieve something similar using &lt;a href=&quot;https://dax.guide/parallelperiod/&quot;&gt;PARALLELPERIOD&lt;/a&gt;, however I’ll leave this up to you!&lt;/p&gt;

&lt;pre&gt;&lt;b&gt;Sales&amp;nbsp;KPI&amp;nbsp;:=&lt;/b&gt;&lt;br /&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;IF&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;[Sales&amp;nbsp;Prior&amp;nbsp;Period]&amp;nbsp;=&amp;nbsp;&lt;span class=&quot;Number&quot; style=&quot;color:#EE7F18&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;BLANK&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&amp;nbsp;[Sales]&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;b&gt;Sales&amp;nbsp;Prior&amp;nbsp;Period&amp;nbsp;:=&lt;/b&gt;&lt;br /&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;VAR&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;LastYear&lt;/span&gt;&amp;nbsp;=&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;CALCULATE&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;[Sales],&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;FILTER&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;ALL&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&amp;nbsp;'Date'[Year]&amp;nbsp;=&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;MAX&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'[Year]&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span class=&quot;Number&quot; style=&quot;color:#EE7F18&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;VAR&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;LastQuarter&lt;/span&gt;&amp;nbsp;=&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;CALCULATE&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;[Sales],&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;FILTER&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;ALL&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;'Date'[QuarterIndex]&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;=&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;MAX&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'[QuarterIndex]&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span class=&quot;Number&quot; style=&quot;color:#EE7F18&quot;&gt;1&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;VAR&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;LastMonth&lt;/span&gt;&amp;nbsp;=&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;CALCULATE&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;[Sales],&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;FILTER&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;ALL&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&amp;nbsp;'Date'[MonthIndex]&amp;nbsp;=&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;MAX&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'[MonthIndex]&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span class=&quot;Number&quot; style=&quot;color:#EE7F18&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;VAR&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;LastWeek&lt;/span&gt;&amp;nbsp;=&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;CALCULATE&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;[Sales],&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;FILTER&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;ALL&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&amp;nbsp;'Date'[WeekIndex]&amp;nbsp;=&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;MAX&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'[WeekIndex]&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&amp;nbsp;-&amp;nbsp;&lt;span class=&quot;Number&quot; style=&quot;color:#EE7F18&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;RETURN&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;IF&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;ISFILTERED&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'[Week]&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;LastWeek&lt;/span&gt;,&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;IF&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;ISFILTERED&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'[Month]&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;LastMonth&lt;/span&gt;,&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;IF&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;ISFILTERED&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'[Quarter]&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;LastQuarter&lt;/span&gt;,&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;IF&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;ISFILTERED&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;'Date'[Year]&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;LastYear&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;BLANK&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent8&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;b&gt;TrendExpression&amp;nbsp;:=&lt;/b&gt;&lt;br /&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;VAR&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;x&lt;/span&gt;&amp;nbsp;=&amp;nbsp;[Sales&amp;nbsp;KPI]&amp;nbsp;/&amp;nbsp;[Sales&amp;nbsp;Prior&amp;nbsp;Period]&lt;br /&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;RETURN&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;indent4&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;IF&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;ISBLANK&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;x&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;BLANK&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;IF&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;x&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span class=&quot;Number&quot; style=&quot;color:#EE7F18&quot;&gt;0.9&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;Number&quot; style=&quot;color:#EE7F18&quot;&gt;-1&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;Keyword&quot; style=&quot;color:#035aca&quot;&gt;IF&lt;/span&gt;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;&amp;nbsp;(&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Variable&quot; style=&quot;color:#49b0af&quot;&gt;x&lt;/span&gt;&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span class=&quot;Number&quot; style=&quot;color:#EE7F18&quot;&gt;1.1&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;Number&quot; style=&quot;color:#EE7F18&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span class=&quot;Number&quot; style=&quot;color:#EE7F18&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&amp;nbsp;&lt;span class=&quot;Parenthesis&quot; style=&quot;color:#808080&quot;&gt;)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;The above TrendExpression can be interpreted as a downwards trend if sales are down more than 10% over the prior period; stable if between -10% and +10% over the prior period; and upwards if over 10% from the prior period.&lt;/p&gt;

&lt;p&gt;Note that when I create the base KPI measure I will usually make a minor adjustment to check for whether the target KPI measure is 0 to avoid divide by 0 errors.&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/KPI-Divide-by-0.png&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;Divide by 0 error on status expression result.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;h2 id=&quot;observation-3-icon-sets-are-based-on-the-implementation-within-the-reporting-tool-and-there-is-no-universal-standard-for-the-graphic-string-identifiers&quot;&gt;Observation 3: Icon sets are based on the implementation within the reporting tool, and there is no universal standard for the graphic string identifiers&lt;/h2&gt;

&lt;p&gt;What I mean by this is that each reporting tool decides on their own implementation of how they will interpret the values (e.g. -1, 0, and 1) received from the StatusExpression and TrendExpression.&lt;/p&gt;

&lt;p&gt;Each client will then view the StatusGraphic [or TrendGraphic] string supplied by the KPI metadata, and if that string corresponds with an icon set, it will substitute the StatusExpression values for the corresponding icons.&lt;/p&gt;

&lt;p&gt;From the &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/mt719113(v=sql.105).aspx&quot;&gt;Analysis Services protocol&lt;/a&gt;: “Because &lt;strong&gt;TrendGraphic&lt;/strong&gt; [and &lt;strong&gt;StatusGraphic&lt;/strong&gt;] is a string property, each client can define and use its own specific set of known values”.&lt;/p&gt;

&lt;p&gt;The below table shows the graphic strings/icon sets I have found and their interpretations in Excel and Power BI. &lt;em&gt;This is not an exhaustive list, feel free to tell me any you have found and I will update this post.&lt;/em&gt;&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/Power-BI-vs-Excel-Status-Icons-1.png&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;Power BI vs Excel Status Icons.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;Below is the same list as included in the image above:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Cylinder&lt;/li&gt;
  &lt;li&gt;Faces&lt;/li&gt;
  &lt;li&gt;Five Bars Colored&lt;/li&gt;
  &lt;li&gt;Five Boxes Colored&lt;/li&gt;
  &lt;li&gt;Gauge&lt;/li&gt;
  &lt;li&gt;Gauge - Ascending&lt;/li&gt;
  &lt;li&gt;Gauge - Descending&lt;/li&gt;
  &lt;li&gt;Reversed Gauge&lt;/li&gt;
  &lt;li&gt;Reversed status arrow&lt;/li&gt;
  &lt;li&gt;Road Signs&lt;/li&gt;
  &lt;li&gt;Road Signs&lt;/li&gt;
  &lt;li&gt;Shapes&lt;/li&gt;
  &lt;li&gt;Shapes&lt;/li&gt;
  &lt;li&gt;Smiley&lt;/li&gt;
  &lt;li&gt;Smiley Face&lt;/li&gt;
  &lt;li&gt;Standard Arrow&lt;/li&gt;
  &lt;li&gt;Status Arrow&lt;/li&gt;
  &lt;li&gt;Thermometer&lt;/li&gt;
  &lt;li&gt;Three Triangles&lt;/li&gt;
  &lt;li&gt;Three Circles Colored&lt;/li&gt;
  &lt;li&gt;Three Flags Colored&lt;/li&gt;
  &lt;li&gt;Three Stars Colored&lt;/li&gt;
  &lt;li&gt;Three Symbols Uncircled Colored&lt;/li&gt;
  &lt;li&gt;Traffic Light&lt;/li&gt;
  &lt;li&gt;Traffic Light - Single&lt;/li&gt;
  &lt;li&gt;Variance Arrow&lt;/li&gt;
  &lt;li&gt;Status Arrow - Ascending&lt;/li&gt;
  &lt;li&gt;Status Arrow - Descending&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;some-notes-about-my-testing&quot;&gt;Some notes about my testing&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;I did not test other client tools such as SSRS.&lt;/li&gt;
  &lt;li&gt;In both Excel and Power BI, all graphics are the same for StatusGraphic and TrendGraphic.&lt;/li&gt;
  &lt;li&gt;Excel inserts an icon-set conditional-format on top of the status number. This can be customized to whatever set of symbols/thresholds you want within the conditional formatting dialog.&lt;/li&gt;
  &lt;li&gt;Power BI strictly converts the StatusExpression results from -2,-1,0,1,2 to an icon set.&lt;/li&gt;
  &lt;li&gt;Excel uses a range to convert the StatusExpression results [for &lt;strong&gt;5 levels&lt;/strong&gt;]:
    &lt;ul&gt;
      &lt;li&gt;Level 1: x &amp;lt;-0.5&lt;/li&gt;
      &lt;li&gt;Level 2: -0.5 &amp;lt;= x &amp;lt; -0.01&lt;/li&gt;
      &lt;li&gt;Level 3: -0.01 &amp;lt;= x &amp;lt; 0.01&lt;/li&gt;
      &lt;li&gt;Level 4: 0.01 &amp;lt;= x &amp;lt; 0.5&lt;/li&gt;
      &lt;li&gt;Level 5: 0.5 &amp;lt;= x&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Excel uses a range to convert the StatusExpression results [for &lt;strong&gt;3 levels&lt;/strong&gt;]:
    &lt;ul&gt;
      &lt;li&gt;Level 1: x &amp;lt;-0.5&lt;/li&gt;
      &lt;li&gt;Level 2: -0.5 &amp;lt;= x &amp;lt; 0.5&lt;/li&gt;
      &lt;li&gt;Level 3: 0.5 &amp;lt;= x&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/Excel-Conditional-Format-KPI.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;Excel conditional formatting options on KPI graphics.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;Excel appears to default to red/yellow/green circles for strings it doesn’t recognize, whereas Power BI defaults to showing the status number.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;tips-for-developing-kpis-in-tabular-editor-updated-312019&quot;&gt;Tips for developing KPIs in Tabular Editor (updated 3/1/2019)&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Create a new measure for your KPI that will evaluate to BLANK if the goal measure is blank or 0.&lt;/li&gt;
  &lt;li&gt;If your goal measure evaluates to 0 (e.g. you have a goal to have 0 workplace injuries), use a “static” goal when creating your StatusExpression.&lt;/li&gt;
  &lt;li&gt;Make your StatusExpression and TrendExpression evaluate to the correct number of icons as per the StatusGraphic/TrendGraphic you select. E.g. if you are using a 5-icon set, evaluate to -2,-1,0,1, or 2. If using 3-icon set, evaluate to -1,0, or 1.&lt;/li&gt;
  &lt;li&gt;When using a 5-icon set and Excel, adjust the conditional format (within Excel) thresholds on the Status/Trend cells to be -2,-1,0, and 1.&lt;/li&gt;
  &lt;li&gt;When adding measures in Power BI using Tabular Editor, don’t forget to delete the automatically generated Translated Name (as Power BI does not support this).&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;kpis-and-their-future-implementation-within-power-bi&quot;&gt;KPIs and their future implementation within Power BI&lt;/h3&gt;

&lt;p&gt;Knowing what we now do, I’m hoping that KPIs can be created natively within Power BI Desktop in the future, hopefully in the same implementation style as Excel.&lt;/p&gt;

&lt;p&gt;There is clearly a demand for it based on the &lt;a href=&quot;https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/9378456-when-will-the-kpi-red-yellow-green-indicators-be-a&quot;&gt;Power BI ideas request here&lt;/a&gt;, most likely it is an issue of technical difficulty versus the payoff.&lt;/p&gt;

&lt;p&gt;My suggestion would be to implement it the same way as in Excel &lt;em&gt;(although I understand there are technical difficulties and possibly even better ways to implement it!)&lt;/em&gt;:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Include a default icon set for unrecognized strings;&lt;/li&gt;
  &lt;li&gt;Use a range rather than static values;&lt;/li&gt;
  &lt;li&gt;Allow the icon set to be changed/customized within PBI.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Finally, I hope that &lt;a href=&quot;https://twitter.com/DOtykier/&quot;&gt;@DOtykier&lt;/a&gt; might read this and update the Status Graphic and Trend Graphic property dropdowns to include the examples above that work! 🙏&lt;/p&gt;

&lt;p&gt;&lt;em&gt;And that’s it! I hope you found this post useful. Feel free to let me know any comments you may have.&lt;/em&gt;&lt;/p&gt;
</description>
        <pubDate>Thu, 03 Jan 2019 08:59:32 +0000</pubDate>
        <link>https://selfservedbi.com/2019/01/03/kpi-follow-up-developing-kpis-in-power-bi-and-analysis-services-using-tabular-editor/</link>
        <guid isPermaLink="true">https://selfservedbi.com/2019/01/03/kpi-follow-up-developing-kpis-in-power-bi-and-analysis-services-using-tabular-editor/</guid>
      </item>
    
      <item>
        <title>KPIs #1: KPI usage in Analysis Services, Excel Power Pivot, and Power BI 🚦</title>
        <description>&lt;p&gt;KPIs, or Key Performance Indicators, are a common way to gauge performance against a set of objectives, and are an integral part of performance management.&lt;/p&gt;

&lt;p&gt;Without getting too deep in jargon, the fundamental idea behind a KPI is that you are comparing some known measure against a target, and then grading the comparison.&lt;/p&gt;

&lt;p&gt;For example, you may decide to compare your actual sales against your budget sales, and then set different percentage grades based on the performance: if sales are above 98% of budget you are “meeting budget”, above 92% you are “near budget”, and below 92% you are “below budget”.&lt;/p&gt;

&lt;p&gt;How many grades you use and the scores you ascribe to them should be based on business needs. Furthermore, which measures get chosen as KPIs by a business, and the process for choosing them, is outside the scope of this article. &lt;em&gt;If you’re interested in this topic you can look up &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Balanced_scorecard&quot;&gt;Balanced Scorecards&lt;/a&gt; and &lt;a href=&quot;https://en.m.wikipedia.org/wiki/Results-based_management&quot;&gt;Results Based Management&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With the above ideas in mind, let’s take a look at how KPIs are implemented within Power Pivot, Analysis Services, and Power BI. However, because all three services use the same underlying Vertipaq engine and share a similar framework, let’s focus on Analysis Services.&lt;/p&gt;

&lt;h3 id=&quot;how-are-kpis-implemented-in-analysis-services&quot;&gt;How are KPIs implemented in Analysis Services?&lt;/h3&gt;

&lt;p&gt;To start us off, it’s useful to reiterate that a KPI uses a base measure, and then compares it against a target. Because it starts off with a base measure, you can think of a KPI as an additional layer sitting on top of the existing measure.&lt;/p&gt;

&lt;p&gt;It’s no coincidence that Analysis Services treat KPIs in the same way.&lt;/p&gt;

&lt;h4 id=&quot;kpi-object-model-hierarchy&quot;&gt;KPI object model hierarchy&lt;/h4&gt;

&lt;p&gt;To illustrate how KPIs are treated, below is the current metadata hierarchy of the KPI object within the Analysis Services &lt;a href=&quot;https://docs.microsoft.com/en-us/bi-reference/tom/introduction-to-the-tabular-object-model-tom-in-analysis-services-amo&quot;&gt;Tabular Object Model (TOM)&lt;/a&gt;, showing the KPI object as a child object to the Measure object.&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/KPI-TOM-Metadata.png&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;Location of the KPI object within the Tabular Object Model, from the Analysis Services Tabular Protocol.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;Because the KPI object is a sub-component of the Measure object, it is worth looking at the properties of the Measure object that will be inherited.&lt;/p&gt;

&lt;h4 id=&quot;measure-object-properties&quot;&gt;Measure object properties&lt;/h4&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/Measure-Object-Properties.png&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;Measure object properties that will be inherited by the KPI object, from the Analysis Services Tabular Protocol.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;
&lt;p&gt;I’d like to emphasise the below measure properties:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Table ID&lt;/li&gt;
  &lt;li&gt;Name&lt;/li&gt;
  &lt;li&gt;FormatString&lt;/li&gt;
  &lt;li&gt;IsHidden&lt;/li&gt;
  &lt;li&gt;DisplayFolder&lt;/li&gt;
  &lt;li&gt;DetailRowsDefinitionID&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means that your KPI will :&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Share the same Table location (unless separated directly into it’s own KPIs location, as in Excel).&lt;/li&gt;
  &lt;li&gt;Have the same name as your underlying measure.&lt;/li&gt;
  &lt;li&gt;Have the same format as your underlying measure.&lt;/li&gt;
  &lt;li&gt;Be hidden if your underlying measure is hidden.&lt;/li&gt;
  &lt;li&gt;Share the same display folder structure as your underlying measure (which can be weird if it is in its own special KPI “table” location, as in Excel).&lt;/li&gt;
  &lt;li&gt;Have the same Detail Rows Definition.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you would not like your KPI to share those properties, the simple solution is to create a new base measure to be used just for your KPI.&lt;/p&gt;

&lt;h4 id=&quot;kpi-object-properties&quot;&gt;KPI object properties&lt;/h4&gt;

&lt;p&gt;In contrast, the below image shows the properties specified directly in the KPI object.&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/KPI-Object-Properties.png&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;KPI object properties, from the Analysis Services Tabular Protocol.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;To aid those descriptions, below are two KPIs as examples: a static KPI with five grades, and a dynamic KPI with 3 grades. By “static” I mean that the goal is a fixed number, whereas a “dynamic” KPI has a goal that is based on another measure.&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/KPI-metadata-example2.png&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;KPI object property examples.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;Now that you’ve had a quick look at the above, I’d like to a call out a few properties:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;TargetExpression&lt;/strong&gt; indicates the goal that needs to be reached. It evaluates to a number. When creating the measure you can choose a static number, or another measure to set as your target.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;StatusExpression&lt;/strong&gt; represents an automatically generated DAX expression that will evaluate to either -2, -1, 0, 1, or 2 for five levels, or -1, 0, or 1 for three levels. The number of levels used is based on the StatusGraphic chosen.&lt;/li&gt;
  &lt;li&gt;Within the &lt;strong&gt;StatusExpression&lt;/strong&gt; DAX formula, if the KPI is based on a static number, these are inputted directly into the expression. If it is instead based on another measure, the expression will divide base measure by the target measure, and use the different percentage amounts as the levels. &lt;strong&gt;Note&lt;/strong&gt;: it is not immediately obvious, but this type of division can cause an issue if the target amount has non-null amounts along one dimension, and the base amount is null along some of the same members of the same dimension. For example, if you input budget sales for next year, but your sales for next year have not yet actually occurred, you will receive an error when pivoting your KPI sales and sales budget along the Year dimension.&lt;/li&gt;
  &lt;li&gt;The &lt;strong&gt;Description&lt;/strong&gt;, &lt;strong&gt;TargetDescription&lt;/strong&gt;, and &lt;strong&gt;StatusDescription&lt;/strong&gt; properties are editable in SSDT through the KPI editor. Curiously, a &lt;strong&gt;ValueDescription&lt;/strong&gt; field appears to be a property editable within the KPI editor, yet is not a property that appears within the KPI object nor the KPI notations object. &lt;em&gt;Weird&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;TrendGraphic&lt;/strong&gt;, &lt;strong&gt;TrendDescription&lt;/strong&gt;, and &lt;strong&gt;TrendExpression&lt;/strong&gt; are &lt;a href=&quot;https://social.msdn.microsoft.com/Forums/officeapps/en-US/ef7cb3db-1132-4223-9f62-31ed0374a61b/can-you-do-kpi-trends-in-tabular&quot;&gt;all currently unused in Analysis Services Tabular&lt;/a&gt; and the Power BI and Excel client tools, despite showing up in the Analysis Services Tabular Protocol (I suspect this is a hangon from Multidimensional model development, yet the feature was not fully executed in Tabular.)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;creating-a-kpi&quot;&gt;Creating a KPI&lt;/h3&gt;

&lt;p&gt;The way it works is that you select a base measure, which could be something like “Sales”.&lt;/p&gt;

&lt;p&gt;You then need to select another measure as your “target” measure, or just type in a static number. Your target measure may be something like “budget sales”, whereas a static number might be “target number of workplace injuries” (which should always be 0!). In the image below I’ve just made a non-sensical selection of “Sales” vs a series of static targets. The icon I’ve selected allows for 5 status levels.&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/KPI-SSDT-Settings-1.png&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;SSDT KPI Editor.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;After having filled in the basic KPI information, you can also insert some descriptions. These don’t seem to appear within the Excel or Power BI client tools, but they’re there if you decide to view the model metadata via DMVs. Note, however, that I couldn’t find the Value Description field in the metadata (although I didn’t look that hard!).&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/KPI-SSDT-Settings-2.png&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;SSDT KPI Editor (descriptions submenu)&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;To give you an idea of the annotations associated with KPIs, you can see the below table where two different KPIs are listed, one static and another dynamic. (Note that their IDs correspond with the KPI IDs above).&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/KPI-Annotations-1.png&quot; width=&quot;600&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;Annotations object for KPIs.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;So now that you’ve hopefully got an understand of how KPIs are developed and their structure within the Tabular Object Model, let’s see how they’re used in the Excel and Power BI client tools.&lt;/p&gt;

&lt;h3 id=&quot;using-kpis-in-power-bi-and-excel&quot;&gt;Using KPIs in Power BI and Excel&lt;/h3&gt;

&lt;p&gt;Unfortunately, KPIs cannot currently be developed within a Power BI model (“dataset”), however, they are able to connect to a Tabular Analysis Services instance and interact with the KPIs there. You can &lt;em&gt;sort of&lt;/em&gt; develop KPIs in Power BI, but not &lt;em&gt;really&lt;/em&gt; (see &lt;a href=&quot;https://sqlserverbi.blog/2018/03/28/how-to-add-kpi-indicators-to-a-table-in-power-bi/&quot;&gt;Paul Turley’s rant here&lt;/a&gt;). This does not apply to models developed in Excel - &lt;a href=&quot;https://support.office.com/en-us/article/key-performance-indicators-kpis-in-power-pivot-e653edef-8a21-40e4-9ece-83a6c8c306aa&quot;&gt;Excel&lt;/a&gt; &lt;strong&gt;&lt;a href=&quot;https://support.office.com/en-us/article/key-performance-indicators-kpis-in-power-pivot-e653edef-8a21-40e4-9ece-83a6c8c306aa&quot;&gt;can&lt;/a&gt;&lt;/strong&gt; &lt;a href=&quot;https://support.office.com/en-us/article/key-performance-indicators-kpis-in-power-pivot-e653edef-8a21-40e4-9ece-83a6c8c306aa&quot;&gt;create KPIs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When you connect to a Tabular Analysis Services model in Power BI you will see that the KPIs are located within the table that they were created in (inherited the TableID property from the Measure object).&lt;/p&gt;

&lt;p&gt;Note that if a table has all columns hidden then it will show as a little calculator in Power BI. Also note that I have a third KPI but it is located in another table based on the measure that it belongs to.&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/KPI-in-PBI.png&quot; width=&quot;300&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;KPIs in Power BI.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;In contrast to Power BI, if you connect to an Tabular Analysis Services instance via Excel you will note that the TableID of the KPI base measure is ignored, and all KPIs are put in their own virtual “table” location called “KPIs”.&lt;/p&gt;

&lt;figure&gt;&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/KPI-in-Excel.png&quot; width=&quot;300&quot; /&gt;&lt;/div&gt;
&lt;figurecaption&gt;&lt;em&gt;KPIs in Excel.&lt;/em&gt;&lt;/figurecaption&gt;&lt;/figure&gt;

&lt;p&gt;An interesting thing to note here is that you can see how the “Sales (KPI)”, which is based on a “Sales” measure inherits the folder structure from the measure object. This can be annoying if you’d like your KPI to have a different folder structure. To change this just create a new measure to base your KPI on with a unique structure.&lt;/p&gt;

&lt;p&gt;In both Power BI and Excel, when you expand the little traffic light icon you’ll find a base, target, and status field.&lt;/p&gt;

&lt;h3 id=&quot;a-few-last-issues&quot;&gt;A few last issues&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Issue 1: Null errors when blank base measure vs non-blank target measure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I alluded to this earlier, but there’s a slightly annoying issue when using KPIs in that if you have a base measure value that returns null while your target measure returns a non-null along the same dimension members, you’ll then either get an error saying that you can’t divide by 0, or you’ll have the much-less-helpful interaction where dropping a field onto the rows or columns area will just. do. nothing…&lt;/p&gt;

&lt;p&gt;Don’t worry, there’s a relatively simple workaround for this, just create a new base measure that references your previous base measure and returns blank if your target measure is 0, else returns your base measure if the target measure is not 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Issue 2: Organizing your KPIs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another issue you may face is that you may end up with two measures that do the same thing, one with a KPI and another without. Normally you’d think, no problem, just hide the new measure but not the KPI. However, you’ll remember from earlier that the KPI inherits the IsHidden property from its parent measure object. So what can you do?&lt;/p&gt;

&lt;p&gt;Well, one thing you can do, and this isn’t a very elegant solution, but you can create a new table, perhaps using a very simple DATATABLE DAX function. Then within this table you just want to stick all of your new base measures with their KPIs. Then when you’re done you should hide your table &lt;em&gt;and&lt;/em&gt; the column(s).&lt;/p&gt;

&lt;p&gt;In Power BI you’ll only see your KPI table surfacing as a little calculator with all of your KPIs underneath it.&lt;/p&gt;

&lt;p&gt;In Excel all of your KPIs will be within the KPI virtual table object, but the table itself and the measures should be hidden (because the table is hidden).&lt;/p&gt;

&lt;p&gt;The other benefit is that you can then have a simplified folder structure for your KPIs.&lt;/p&gt;

&lt;p&gt;This also lets you re-organize how the KPIs will be arranged into different folders within the KPI section rather than how the regular base measures would have been (because KPIs use the same folder structure as their base measures, which can be very annoying if you have many many measures and want a different structure for the KPIs).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Closing remarks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Power BI (Premium) is currently on a mission to envelop all of the features included within Analysis Services Tabular, so it will be interesting to see how and if KPI development ever makes its way into Power BI! Here’s to hoping that it makes its way in!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (3/1/2019)&lt;/strong&gt;: If you’d like to continue exploring KPIs and their development using Tabular Editor, please read on to the &lt;a href=&quot;/2019/01/03/kpi-follow-up-developing-kpis-in-power-bi-and-analysis-services-using-tabular-editor/&quot;&gt;follow up post here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;And that’s it. If you found this brief discussion on KPIs in Analysis Services Tabular useful, let me know.&lt;/em&gt;&lt;/p&gt;
</description>
        <pubDate>Fri, 28 Dec 2018 11:29:54 +0000</pubDate>
        <link>https://selfservedbi.com/2018/12/28/kpis-and-their-usage-in-analysis-services-excel-power-pivot-and-power-bi-%f0%9f%9a%a6/</link>
        <guid isPermaLink="true">https://selfservedbi.com/2018/12/28/kpis-and-their-usage-in-analysis-services-excel-power-pivot-and-power-bi-%f0%9f%9a%a6/</guid>
      </item>
    
      <item>
        <title>Creating a date table in Power Query</title>
        <description>&lt;p&gt;&lt;em&gt;I use “columns” and “fields” interchangeably in this post.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There are many posts out there showing how to create a date table and I believe this is because it’s a common problem that almost everyone encounters when first making a data model in Power BI, Excel, or Analysis Services.&lt;/p&gt;

&lt;p&gt;By “common problem” I mean that it’s the one dimension that almost every data model shares, and fitting it to your data model can sometimes be a bit tricky.&lt;/p&gt;

&lt;p&gt;You can create date tables in &lt;a href=&quot;https://stackoverflow.com/questions/5635594/how-to-create-a-calendar-table-for-100-years-in-sql&quot;&gt;SQL&lt;/a&gt;, &lt;a href=&quot;https://www.sqlbi.com/articles/reference-date-table-in-dax-and-power-bi/&quot;&gt;DAX&lt;/a&gt;, &lt;a href=&quot;https://exceleratorbi.com.au/build-reusable-calendar-table-power-query/&quot;&gt;M&lt;/a&gt;, and many other programming languages.&lt;/p&gt;

&lt;p&gt;In this post I want to show you how you can make a date table in Power Query’s M language, as well as explain what fields I think are important and how you can create them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: There’s info out there about whether you should join your fact table dates to your date table on date columns or date-integer columns, as well as whether you should “mark as date table”. For now, however, these topics are not within the scope of this post. &lt;em&gt;I join my tables on a date column and I do not mark my custom date tables as date. A video by Patrick Leblanc &lt;strong&gt;&lt;a href=&quot;https://youtu.be/i8aKjGZd5kY&quot;&gt;here&lt;/a&gt;&lt;/strong&gt; can start you down that topic.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;what-makes-a-good-date-table&quot;&gt;What makes a good date table?&lt;/h3&gt;
&lt;p&gt;This can almost be rephrased as “what columns should I include in a date table”. I’ll list what columns I think are important further below, but in the mean time, here are some other characteristics of a good date table:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good characteristic 1: Only include columns that you know you will use, or think you will use at least once.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My philosophy when making a date table (and data modelling in general) is: &lt;em&gt;“I want what I want and nothing that I don’t”&lt;/em&gt;, meaning that I only include columns that I know I will use, albeit if infrequently. In this regard I generally start off with a minimalist attitude and add more columns as I go.&lt;/p&gt;

&lt;p&gt;If you do find yourself with an overly cluttered model, you can always use &lt;a href=&quot;https://github.com/otykier/TabularEditor/wiki/Best-Practice-Analyzer#finding-unused-objects&quot;&gt;Tabular Editor and the Best Practice Analyzer feature&lt;/a&gt; or &lt;a href=&quot;https://github.com/otykier/TabularEditor/wiki/Roadmap#ui-for-showing-object-dependencies&quot;&gt;view dependencies&lt;/a&gt; to see where you can prune your model. &lt;strong&gt;(Small update&lt;/strong&gt;: &lt;a href=&quot;https://www.reddit.com/user/Data_cruncher&quot;&gt;u/data_cruncher&lt;/a&gt; has suggested I also include &lt;a href=&quot;https://www.sqlbi.com/tools/vertipaq-analyzer/&quot;&gt;Vertipaq Analyzer&lt;/a&gt;, a handy tool for quickly analyzing data models in Excel - thanks for the tip! I might even do a future post dedicated to this tool and DMVs).&lt;/p&gt;

&lt;p&gt;Kasper’s post &lt;a href=&quot;https://www.kasperonbi.com/determine-columns-you-dont-need-using-dmvs-in-power-bi&quot;&gt;here&lt;/a&gt; also explains how and why you should remove unused columns. Note that a few extra columns on a dimension table such as this date table will make barely any difference to the size of your model, so from an optimisation point of view having a few extra columns is not a big deal.&lt;/p&gt;

&lt;p&gt;If you add too many columns to your model, or individual tables, it can quickly become cluttered, and before you know it you might have difficulty understanding your model.&lt;/p&gt;

&lt;p&gt;This leads me to my next “good characteristic” of a date table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good characteristic 2: Make sure that you understand your date table.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you don’t understand how it was made or what the columns mean, it can be confusing to add new columns in the future that weren’t originally included. This is part of the reason why I don’t use the &lt;a href=&quot;https://www.sqlbi.com/articles/reference-date-table-in-dax-and-power-bi/&quot;&gt;fantastic DAX date table available on SQLBI&lt;/a&gt; (however I do look to it for inspiration!).&lt;/p&gt;

&lt;p&gt;While the “width” of your date table is very important and you should always try to avoid unnecessary columns, it is also somewhat important to consider the “length” of your date table, which leads to…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good characteristic 3: Make sure the range of dates is appropriate for your data model.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By this I mean make sure that you include enough historical and future date rows in your date table so that you can be comfortable that each date in all of your fact tables can find a corresponding date in your date table.&lt;/p&gt;

&lt;p&gt;It’s often suggested to use the maximum date from a particular fact table to determine a dynamic maximum date on your date table.&lt;/p&gt;

&lt;p&gt;While this dynamic maximum can be done relatively easily in DAX, and perhaps slightly less easily in M (and perhaps even less easily when using M in Analysis Services unless you’re using expressions), I, however, think this is unnecessary and can create complications if you decide to later add new fact tables that have dates in the future (such as budget tables or 5-year plans).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If the reason you’re linking your date table’s maximum date to a fact table is to avoid your “Sales YTD” or other measures running into future periods, you can just filter the measure so that it must be before the current date.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But enough about “good characteristics” of a date table..&lt;/p&gt;

&lt;h3 id=&quot;which-fields-should-you-include&quot;&gt;Which fields should you include?&lt;/h3&gt;

&lt;p&gt;I’ve organized the fields into the 3 groups below:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Standard descriptors&lt;/li&gt;
  &lt;li&gt;Combined descriptors&lt;/li&gt;
  &lt;li&gt;Indexes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Standard descriptors&lt;/strong&gt; provide common ways of describing your data. Generally included in this category are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Date&lt;/li&gt;
  &lt;li&gt;Day Name&lt;/li&gt;
  &lt;li&gt;Year&lt;/li&gt;
  &lt;li&gt;Half-year&lt;/li&gt;
  &lt;li&gt;Trimester&lt;/li&gt;
  &lt;li&gt;Quarter&lt;/li&gt;
  &lt;li&gt;Month&lt;/li&gt;
  &lt;li&gt;Week&lt;/li&gt;
  &lt;li&gt;IsWeekend&lt;/li&gt;
  &lt;li&gt;IsHoliday&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Combined descriptors&lt;/strong&gt; provide a way to uniquely filter rows in your report. For example, to exclude December 2018 from your report without excluding December 2017 it is handy to have a “year-month” field to use as your filter (as filtering in just December will remove all occurances of December, regardless of year).&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Year - Quarter&lt;/li&gt;
  &lt;li&gt;Year - Month&lt;/li&gt;
  &lt;li&gt;Year - Week&lt;/li&gt;
  &lt;li&gt;Year - Month - Week&lt;/li&gt;
  &lt;li&gt;Date - Day Name&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Indexes&lt;/strong&gt; provide a way to make comparisons of your data for YTD and other period based measures.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Week index&lt;/li&gt;
  &lt;li&gt;Month index&lt;/li&gt;
  &lt;li&gt;Quarter index&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;building-the-date-table&quot;&gt;Building the date table&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Step 1: Parameters&lt;/strong&gt;
Begin your table by declaring a start date, end date, and optionally the culture to use for month names later on.&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Enter start and end dates (format YYYY,MM,DD)&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;StartDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2010&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;EndDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2029&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;Culture&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;en-US&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Examples: en-US, nl-NL, zh-ZH, etc.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next you want to generate the date list based on your start and end dates.&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Generate date list from variables above (start and end years), convert list to table, rename, convert to dates&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;DayCount&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Days&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;From&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;EndDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;StartDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;GenerateDates&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Dates&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartDate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DayCount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;TableConversion&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;FromList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;GenerateDates&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Splitter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SplitByNothing&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ExtraValues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;RenamedColumns&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RenameColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TableConversion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Column1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Date&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;DateTypeChange&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TransformColumnTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RenamedColumns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Date&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}}),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Inserting the year and week&lt;/strong&gt;
Once you have an ordered list of dates, you will want to insert the year and week.&lt;/p&gt;

&lt;p&gt;Getting the week number can be tricky if you want to use the ISO standard week number or similar variants. If you don’t need an ISO week then you’re in luck and can just use the Date.WeekOfYear function, but for this post I’ll include how to get an ISO week.&lt;/p&gt;

&lt;p&gt;For reference, here’s an old &lt;a href=&quot;https://social.technet.microsoft.com/Forums/en-US/2a85c825-c75b-4622-98a1-25547dec49c8/enhancement-request-iso-week-number?forum=powerquery&quot;&gt;feature request&lt;/a&gt; that explains the issue and hopes for an update to the Date.WeekOfYear function to accept arguments similar to the Excel WEEKNUM function (which can correctly calculate the ISO week number). Interestingly, this has been a feature request for quite a while and is not yet implemented. Calling on &lt;a href=&quot;https://twitter.com/mllopis&quot;&gt;Miguel Llopsis&lt;/a&gt; if he may know of any plans on the drawing board! FYI you can vote for an update to the Date.WeekOfYear function on &lt;a href=&quot;https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/13507155-iso-week-number-option-on-date-weekofyear-function&quot;&gt;the Power BI Ideas forum here&lt;/a&gt;.
To get your ISO week, use the following code:&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Insert a standard year, insert a reference date, insert ISO8601 week number using ref date&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertYear&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DateTypeChange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertRefDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertYear&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;RefDate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertISOWeek&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertRefDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;IntegerDivide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Days&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]-[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])+&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DayOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;IntegerDivide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Days&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]-[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])+&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DayOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Note if you wanted an exact ISO year you can use the below (although I don’t use this because financial year-ends are the same date each year):&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;InsertYear&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DateTypeChange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOYear&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddDays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DayOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))),&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The way that getting the ISO week works is that it adds up the difference between the current date and the reference date, adds on the day of the week of the reference date, and then adds another 7. (For a correct ISO week beginning on Monday you add 6 and use 0 for your Date.DayOfWeek argument), for a week beginning Sunday you add 7 and use 1 for your Date.DayOfWeek argument).&lt;/p&gt;

&lt;p&gt;You then take this number and divide it by 7, ignoring any remainder.&lt;/p&gt;

&lt;p&gt;Worked examples are always very useful, so let’s use the 9th and 10th of January 2016. In these examples we’re saying that the week starts on a Sunday (not strictly ISO).&lt;/p&gt;

&lt;pre&gt;
&lt;FONT COLOR=&quot;BLUE&quot;&gt;Example 1: ISO Week of 9 January 2016&lt;/FONT&gt;
&lt;FONT COLOR=&quot;GREY&quot;&gt;1:&lt;/FONT&gt; 9/1/2016 - 3/1/2016 = 6 &lt;FONT COLOR=&quot;GREY&quot;&gt;//Get difference between current and reference date&lt;/FONT&gt;
&lt;FONT COLOR=&quot;GREY&quot;&gt;2:&lt;/FONT&gt; 3/1/2016 is a Sunday = 0 &lt;FONT COLOR=&quot;GREY&quot;&gt;//Reference date is a Sunday (0 to 6, Sunday to Saturday)&lt;/FONT&gt;
&lt;FONT COLOR=&quot;GREY&quot;&gt;3:&lt;/FONT&gt; Add 7 = 7
&lt;FONT COLOR=&quot;GREY&quot;&gt;4:&lt;/FONT&gt; 6+0+7=13 &lt;FONT COLOR=&quot;GREY&quot;&gt;//Add results of 3 previous calculations&lt;/FONT&gt;
&lt;FONT COLOR=&quot;GREY&quot;&gt;5:&lt;/FONT&gt; 13/7 = &lt;FONT COLOR=&quot;RED&quot;&gt;1&lt;/FONT&gt; (ignore the remainder), Saturday 9 January 2016 is in week &lt;FONT COLOR=&quot;RED&quot;&gt;1&lt;/FONT&gt;
 
&lt;FONT COLOR=&quot;BLUE&quot;&gt;Example 2: ISO Week of 10 January 2016&lt;/FONT&gt;
&lt;FONT COLOR=&quot;GREY&quot;&gt;1:&lt;/FONT&gt; 10/1/2016 - 3/1/2016 = 7
&lt;FONT COLOR=&quot;GREY&quot;&gt;2:&lt;/FONT&gt; 3/1/2016 is a Sunday = 0
&lt;FONT COLOR=&quot;GREY&quot;&gt;3:&lt;/FONT&gt; Add 7 = 7
&lt;FONT COLOR=&quot;GREY&quot;&gt;4:&lt;/FONT&gt; 7+0+7=14
&lt;FONT COLOR=&quot;GREY&quot;&gt;5:&lt;/FONT&gt; 14/7 = &lt;FONT COLOR=&quot;RED&quot;&gt;2&lt;/FONT&gt; (ignore the remainder), Sunday 10 January 2016 is in week &lt;FONT COLOR=&quot;RED&quot;&gt;2&lt;/FONT&gt;
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Inserting the months and quarters&lt;/strong&gt;
After getting your weeks sorted, you can then insert the months. If you want calendar months then you can just use Date.Month, otherwise you can use the below series of if statements for how to code for 4-4-5 months.&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Insert the Month Number based on the Week numbers, change it to the number type&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertISOMonth&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertISOWeek&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;2&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;3&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;17&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;4&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;21&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;5&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;26&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;6&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;7&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;34&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;8&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;39&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;9&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;43&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;10&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;47&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;11&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;12&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOMonthTypeChange&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TransformColumnTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertISOMonth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}}),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After you’ve got your month numbers you can insert the corresponding month name. Note that if you add the “culture” parameter defined earlier it will change the language of the month name.&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Insert the month name that corresponds with the ISOMonth, then reorder the columns&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertISOMonthName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonthTypeChange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthName&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ToText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;MMMM&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Culture&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertISOQuarter&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertISOMonthName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Q1&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Q2&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Q3&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Q4&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOQuarterTypeChange&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TransformColumnTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertISOQuarter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}}),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Insert the combined descriptors&lt;/strong&gt;
For now I’ll just be adding in some simple combined descriptors, but you may want to add others or different variants.&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Insert &quot;YYYY-WWW&quot; column, &quot;YYY-MMM&quot; column, remove the reference date&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertYrWk&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOQuarterTypeChange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YrWk&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ToText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;amp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ToText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-W00&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertYrMn&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertYrWk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;YrMn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ToText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;amp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ToText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-MMM&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Culture&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;RemoveRefDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoveColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertYrMn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;RefDate&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Insert the indexes&lt;/strong&gt;
One of the final steps is to add in the indexes for use in time intelligence measures.&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Create ISOWeek Index Table&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTableSelectColumns&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SelectColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoveRefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTableSelectDistinct&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Distinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTableSelectColumns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddIndexColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTableSelectDistinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeekIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Create ISOMonth Index Table&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTableSelectColumns&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SelectColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoveRefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTableSelectDistinct&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Distinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTableSelectColumns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddIndexColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTableSelectDistinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Create ISOQuarter Index Table&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTableSelectColumns&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SelectColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoveRefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTableSelectDistinct&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Distinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTableSelectColumns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddIndexColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTableSelectDistinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarterIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The way that this works is that you’re grabbing your most recent step, selecting the year and other column that you want to make an index on, getting their distinct values, and then creating an index column. &lt;em&gt;Remember, just because the query editor puts each step after the other doesn’t mean you can’t re-use steps for other purposes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After creating your index tables you can then join them into your main table:&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Join Index Tables&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;MergedISOWeekIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;NestedJoin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoveRefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;JoinKind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LeftOuter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOWeekIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandTableColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MergedISOWeekIndexTable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOWeekIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOWeekIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;MergedISOMonthIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;NestedJoin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOWeekIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;JoinKind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LeftOuter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOMonthIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandTableColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MergedISOMonthIndexTable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;MergedISOQuarterIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;NestedJoin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOMonthIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;JoinKind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LeftOuter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOQuarterIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandTableColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MergedISOQuarterIndexTable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarterIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarterIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, you may want to do a reorder of your columns and a type change.&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;ReorderColumns&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ReorderColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOQuarterIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Date&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarterIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthName&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeekIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YrMn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YrWk&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;TypeChange&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TransformColumnTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ReorderColumns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarterIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOWeekIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}})&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TypeChange&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;All the code in one block can be found below:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Enter start and end dates (format YYYY,MM,DD)&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;StartDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2010&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;EndDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2029&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;Culture&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;en-US&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Examples: en-US, nl-NL, zh-ZH, etc.&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Generate date list from variables above (start and end years), convert list to table, rename, convert to dates&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;DayCount&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Days&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;From&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;EndDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;StartDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;GenerateDates&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Dates&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartDate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DayCount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;TableConversion&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;FromList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;GenerateDates&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Splitter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SplitByNothing&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ExtraValues&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;RenamedColumns&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RenameColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TableConversion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Column1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Date&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;DateTypeChange&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TransformColumnTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RenamedColumns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Date&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}}),&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Insert a standard year, insert a reference date, insert ISO8601 week number using ref date&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertYear&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DateTypeChange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertRefDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertYear&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;RefDate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertISOWeek&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertRefDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;IntegerDivide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Days&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]-[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])+&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DayOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;IntegerDivide&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Days&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]-[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])+&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DayOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Insert the Month Number based on the Week numbers, change it to the number type&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertISOMonth&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertISOWeek&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;1&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;2&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;3&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;17&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;4&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;21&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;5&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;26&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;6&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;7&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;34&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;8&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;39&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;9&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;43&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;10&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;47&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;11&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;12&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOMonthTypeChange&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TransformColumnTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertISOMonth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}}),&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Insert the month name that corresponds with the ISOMonth, then reorder the columns&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertISOMonthName&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonthTypeChange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthName&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ToText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;MMMM&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Culture&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertISOQuarter&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertISOMonthName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Q1&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Q2&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Q3&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Q4&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOQuarterTypeChange&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TransformColumnTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertISOQuarter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}}),&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Insert &quot;YYYY-WWW&quot; column, &quot;YYY-MMM&quot; column, remove the reference date&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertYrWk&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOQuarterTypeChange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YrWk&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ToText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;amp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ToText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;-W00&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;InsertYrMn&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertYrWk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;YrMn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ToText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;amp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ToText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],[&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;-MMM&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Culture&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;RemoveRefDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoveColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InsertYrMn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;RefDate&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Create ISOWeek Index Table&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTableSelectColumns&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SelectColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoveRefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTableSelectDistinct&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Distinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTableSelectColumns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddIndexColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTableSelectDistinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeekIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Create ISOMonth Index Table&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTableSelectColumns&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SelectColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoveRefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTableSelectDistinct&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Distinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTableSelectColumns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddIndexColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTableSelectDistinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Create ISOQuarter Index Table&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTableSelectColumns&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SelectColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoveRefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTableSelectDistinct&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Distinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTableSelectColumns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddIndexColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTableSelectDistinct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarterIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Join Index Tables&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;MergedISOWeekIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;NestedJoin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;RemoveRefDate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOWeekIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;JoinKind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LeftOuter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOWeekIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandTableColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MergedISOWeekIndexTable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOWeekIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOWeekIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;MergedISOMonthIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;NestedJoin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOWeekIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOMonthIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;JoinKind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LeftOuter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOMonthIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandTableColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MergedISOMonthIndexTable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;MergedISOQuarterIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;NestedJoin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOMonthIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ISOQuarterIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;JoinKind&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LeftOuter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOQuarterIndexTable&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandTableColumn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MergedISOQuarterIndexTable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;NewColumn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarterIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarterIndex&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;ReorderColumns&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ReorderColumns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ExpandMergedISOQuarterIndexTable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Date&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarterIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthName&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ISOWeekIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YrMn&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YrWk&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}),&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;TypeChange&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TransformColumnTypes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ReorderColumns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,{{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOQuarterIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOMonth&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOMonthIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOWeek&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ISOWeekIndex&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}})&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; 
    &lt;span class=&quot;nc&quot;&gt;TypeChange&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I hope you’ve found this waffle-y post useful. If you find any errors or think I’ve missed something, please let me know and I’ll add it to this post!&lt;/p&gt;
</description>
        <pubDate>Tue, 25 Dec 2018 09:08:00 +0000</pubDate>
        <link>https://selfservedbi.com/2018/12/25/creating-a-date-table-in-power-query/</link>
        <guid isPermaLink="true">https://selfservedbi.com/2018/12/25/creating-a-date-table-in-power-query/</guid>
      </item>
    
      <item>
        <title>Workarounds for Analysis Services database admins without server admin access</title>
        <description>&lt;p&gt;&lt;em&gt;This is a somewhat obscure topic, but I hope that others (if they ever find themselves in this position) find it useful!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In Analysis Services you can have &lt;a href=&quot;https://docs.microsoft.com/en-us/sql/analysis-services/instances/grant-server-admin-rights-to-an-analysis-services-instance?view=sql-server-2017&quot;&gt;administrator rights over an entire server instance&lt;/a&gt;, as well as &lt;a href=&quot;https://docs.microsoft.com/en-us/sql/analysis-services/multidimensional-models/grant-database-permissions-analysis-services?view=sql-server-2017&quot;&gt;administrator rights over particular databases&lt;/a&gt; on the server instance.&lt;/p&gt;

&lt;p&gt;To give an example, let’s say that an organisation has a structure where there is one server administrator responsible for managing the Analysis Services server, and many database administrators responsible for developing, deploying, and updating particular database models hosted on that server.&lt;/p&gt;

&lt;p&gt;This situation may become more common as organizations move their infrastructure to the cloud and consolidate server deployments to Azure Analysis Services. When this happens there may be multiple developers working on different models all hosted by a single server that supports a specific country/region.&lt;/p&gt;

&lt;p&gt;In this example there are limitations that these database admins may face because they are not also server admins.&lt;/p&gt;

&lt;p&gt;To get straight to the point, listed below are the main limitations that I have found so far, as well as any workarounds.&lt;/p&gt;

&lt;h2 id=&quot;limitation-1-database-admins-cannot-create-new-databases&quot;&gt;Limitation 1: Database admins cannot create new databases&lt;/h2&gt;

&lt;p&gt;I wasn’t sure whether to include this limitation or not because it’s obvious.&lt;/p&gt;

&lt;p&gt;Without the database existing, it follows that there is no database for you to have database administrator access over.&lt;/p&gt;

&lt;p&gt;There is no workaround.&lt;/p&gt;

&lt;p&gt;In this scenario you just need a server administrator to create a new database and create a role within it that has administrator access, and then add you to that role.&lt;/p&gt;

&lt;h2 id=&quot;limitation-2-database-admins-cannot-deploy-a-model-to-the-server-using-restricted-data-source-settings-such-as-impersonation-mode-except-when-using-bism-normalizer&quot;&gt;Limitation 2: Database admins cannot deploy a model to the server using restricted data source settings such as impersonation mode (&lt;em&gt;except when using BISM-Normalizer&lt;/em&gt;)&lt;/h2&gt;

&lt;p&gt;I’m not sure if this is a bug within Analysis Services or working as intended. But the result seems to be that for the vast majority of the time, you can’t deploy your model using SSDT (or &lt;a href=&quot;https://tabulareditor.github.io/&quot;&gt;Tabular Editor&lt;/a&gt;!).&lt;/p&gt;

&lt;p&gt;The problem you will encounter is that you are unable to deploy updated model metadata via SSDT to a database that you are the administrator over if the metadata contains an ImpersonationMode (e.g. the data source settings include impersonation of another account).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Information on impersonation from &lt;a href=&quot;https://docs.microsoft.com/en-us/sql/analysis-services/tabular-models/impersonation-ssas-tabular?view=sql-server-2017&quot;&gt;Microsoft docs here&lt;/a&gt;, a forum post &lt;a href=&quot;https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b54944ad-bf8a-4a45-9264-e52a3f501071/the-impersonationinfo-for-datasource-contains-an-impersonationmode-that-can-only-be-used-by-a-server?forum=sqlanalysisservices&quot;&gt;where the “workaround” is to just make them a server admin here&lt;/a&gt;, and &lt;a href=&quot;http://www.biadmin.com/2012/08/ssas-2012-gotcha-impersonation-info-in.html&quot;&gt;another sort of workaround here, but may not necessarily apply to Tabular&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The error message looks like this:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;------ Deploy started: Project: VSProject, Configuration: Development x86 ------
Cannot deploy metadata. Reason: Failed to save modifications to the server. 
Error returned: 'The ImpersonationInfo for datasource contains an ImpersonationMode that can only be used by a server administrator.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/SSDT-Cannot-Deploy-to-AAS.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;

&lt;p&gt;Unfortunately, you also receive the same error when deploying from Tabular Editor, which hints at the fact that these two tools may have similar deployment methods.&lt;/p&gt;

&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/Tabular-Editor-Cannot-Deploy-to-AAS.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;p&gt;Tabular Editor also cannot deploy without server admin rights when using ImpersonationMode settings[/caption]&lt;/p&gt;

&lt;p&gt;Note that there also appears to be a bug with Tabular Editor in that AAS role members cannot be deployed to an AAS model. If you test this out for yourself make sure you don’t include role members, otherwise you may receive a different error before you get to the ImpersonationMode error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The workaround:&lt;/strong&gt; here’s where it gets interesting, you can actually avoid this error message by deploying via &lt;a href=&quot;http://bism-normalizer.com/&quot;&gt;BISM-Normalizer&lt;/a&gt;. I’m not sure yet what black magic is used to make this work, but it’s obviously related to the deployment methods. Paging &lt;a href=&quot;https://twitter.com/_christianWade&quot;&gt;@_christianWade&lt;/a&gt; if he’s able to shed any light on this!&lt;/p&gt;

&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/BISM-Normalizer-Deploy-to-AAS.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;p&gt;Deploying metadata without server admin rights via BISM-Normalizer is successful! However server profile traces are not allowed.&lt;/p&gt;

&lt;p&gt;I’ve had a look at the deployment trace files and can’t seem to figure out how BISM-Normalizer is doing it, but I’ll keep exploring and will update this post if I find anything interesting. I have a sinking feeling it might require &lt;a href=&quot;https://msdn.microsoft.com/library/mt719260&quot;&gt;looking through the SSAS Tabular protocol&lt;/a&gt;…&lt;/p&gt;

&lt;p&gt;A quick tip: make sure that if you want a full deployment via BISM-Normalizer that you include everything you mean to. (e.g. including partitions / perspectives / roles / members / etc.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Limitation 3: Database admins cannot set up server-side automated refreshing of data (aka “processing”).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are many different ways to automate the “processing” of your model. Processing is the term used to refresh the data and perform static calculations such as re-calculating DAX columns or tables.&lt;/p&gt;

&lt;p&gt;In Azure, from what I’ve seen so far, most methods rely on &lt;a href=&quot;https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-addservprinc-admins&quot;&gt;adding a service credential to the list of server administrators&lt;/a&gt; or using a server administrator’s credentials. (while on this topic, &lt;a href=&quot;https://blogs.technet.microsoft.com/uktechnet/2018/06/22/how-to-automate-processing-your-azure-analysis-services-models/&quot;&gt;running your automation through a runbook&lt;/a&gt; means you can only refresh as often as once per hour, although there are &lt;a href=&quot;https://azure.microsoft.com/en-au/blog/automating-azure-analysis-services-processing-with-azure-functions/&quot;&gt;other methods&lt;/a&gt; in AAS to have quicker processing).&lt;/p&gt;

&lt;p&gt;In on-premises I believe it relies on the SQL Server Agent using proxy credentials of a server administrator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Workaround&lt;/em&gt;&lt;/strong&gt;&lt;em&gt;:&lt;/em&gt; Get around this by using remote process execution via PS + Task Scheduler. &lt;a href=&quot;/2018/12/14/how-to-automate-azure-analysis-services-processing-from-a-remote-pc/&quot;&gt;I made a post last week on how to do this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Limitation 4: Database admins have limited query tracing capability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Note that when you use BISM-Normalizer to deploy your model, you will receive the error message (above) after it has been deployed saying that a server trace was unable to be captured.&lt;/p&gt;

&lt;p&gt;The reason for this error message is because only server admins can capture trace events…&lt;em&gt;sort of&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;If you connect SQL Server Profiler to a server you might have to wait for a minute or two but it should eventually connect in a somewhat limited fashion, and you actually can capture what appear to be partial traces of queries sent to the database on the server. (Similar to how you can see most “DISCOVER” &lt;a href=&quot;https://docs.microsoft.com/en-us/sql/analysis-services/instances/use-dynamic-management-views-dmvs-to-monitor-analysis-services?view=sql-server-2017&quot;&gt;Dynamic Management Views&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;This makes sense because if you’re querying a server, you should only be able to see the queries that relate to the databases that you administer, however there are also many events that relate to the server in general, such as connection attempts with the server itself, as well as queries to other databases.&lt;/p&gt;

&lt;p&gt;Note that when using SQL Server Profiler to connect to Analysis Services you only specify the server, not the actual database, although the database &lt;em&gt;can&lt;/em&gt; be filtered using the row filter settings once you’re connected.&lt;/p&gt;

&lt;p&gt;Sadly, part of not being able to perform traces means that &lt;a href=&quot;http://daxstudio.org/&quot;&gt;DAX Studio&lt;/a&gt; runs into fatal errors or displays the same error message as when you deployed the model using BISM-Normalizer.&lt;/p&gt;

&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/DAX-Studio-Cannot-Do-Trace.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;

&lt;p&gt;This means that testing/optimizing your queries on the production instance will not work, and instead you’ll just have to deploy it to a local developer instance or another server in which you have administrator rights.&lt;/p&gt;

&lt;p&gt;Note that you can still get most Dynamic Management Views, with the exception of some DISCOVER views that require server administrator permissions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Closing remarks and a guess at the future&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hopefully in the future SSDT and Tabular editor can overcome this deployment issue, however the workaround isn’t that painful and using BISM-Normalizer for deployments (especially to a production database) is probably a best practice anyway!&lt;/p&gt;

&lt;p&gt;In regards to how this relates to Power BI, hopefully the “publishing”(deployment) of Power BI “datasets”(models) to PBI “workspaces”(server instances) is done in a similar way to BISM-Normalizer instead of the current PBI publishing method or the method that SSDT and Tabular Editor use.&lt;/p&gt;

&lt;p&gt;To get a glimpse at this, see the &lt;a href=&quot;https://maqsoftware.com/case-studies/alm-toolkit&quot;&gt;MAQ software ALM toolkit for Power BI&lt;/a&gt;, and this display by &lt;a href=&quot;https://www.microsoft.com/en-us/businessapplicationssummit/video/BAS2018-204&quot;&gt;Amir Netz at the Business Applications Summit 2018&lt;/a&gt;, starts at 26:30.&lt;/p&gt;
</description>
        <pubDate>Sat, 22 Dec 2018 08:03:19 +0000</pubDate>
        <link>https://selfservedbi.com/2018/12/22/workarounds-for-analysis-services-database-admins-without-server-admin-access/</link>
        <guid isPermaLink="true">https://selfservedbi.com/2018/12/22/workarounds-for-analysis-services-database-admins-without-server-admin-access/</guid>
      </item>
    
      <item>
        <title>Converting from UTC to Local Timezone in Power BI and Azure Analysis Services</title>
        <description>&lt;p&gt;This post is a quick response / supplement to Kasper’s post “&lt;a href=&quot;https://www.kasperonbi.com/show-the-refresh-datetime-in-a-power-bi-report-and-dash&quot;&gt;Show the refresh date\time in a Power BI report and dashboard&lt;/a&gt;”.&lt;/p&gt;

&lt;p&gt;Currently there is a small issue when using the DateTime.LocalNow() (and other similar functions) within the Power BI Service or Azure Analysis Services when processing a refresh of data.&lt;/p&gt;

&lt;p&gt;The issue is that the server will record a refresh time using Universal Coordinated Time (UTC), rather than the specific time zone that the server is located in.&lt;/p&gt;

&lt;p&gt;(Note that UTC is the same as Greenwich Mean Time, GMT).&lt;/p&gt;

&lt;p&gt;There are some great resources out there for solving this problem (particularly &lt;a href=&quot;http://radacad.com/solving-dax-time-zone-issue-in-power-bi&quot;&gt;this post by Reza Rad&lt;/a&gt;, but I thought I’d add in one more hard-coded solution for those tricky times where you can’t or don’t want to connect to a web source and are operating in a time zone that has daylight savings.&lt;/p&gt;

&lt;p&gt;The “best” solutions often say that you should query a web service or grab the correct time for your location from a web site. Although I’d counter that by asking:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Do you really want to add yet another query to your model?&lt;/li&gt;
  &lt;li&gt;How about a query that’s dependent upon a potentially unreliable external web source?&lt;/li&gt;
  &lt;li&gt;What do you do if you’re using Analysis Services and there is no “from web” connector available?&lt;/li&gt;
  &lt;li&gt;Is it actually that hard to just code in the daylight savings time difference using an M formula in Power Query?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answers to the above are: No, no, you’re sh*t out of luck, and no.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When do daylight savings occur?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It’s not borne from a crystal ball, and neither are there specialists throwing darts at a calendar. When you look at &lt;a href=&quot;https://en.wikipedia.org/wiki/Daylight_saving_time_by_country&quot;&gt;when daylight savings changes actually occur&lt;/a&gt;, they’re pretty much universally on a Sunday and also usually on a particular week of the month, with “the first Sunday of x month” popping up quite often.&lt;/p&gt;

&lt;p&gt;Because I’m from Melbourne (Australia, not Florida) and we fit into a common category, I’ll try to explain the M code for calculating from the server’s local datetime (aka UTC time) to Melbourne time.&lt;/p&gt;

&lt;p&gt;Firstly, you want to grab the current year.&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LocalNow&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Secondly, you need to grab the daylight savings dates.&lt;/p&gt;

&lt;p&gt;In Melbourne, daylight savings is defined by the first Sunday of April and the first Sunday of October. By working from the inside out of the formula outwards it is a bit easier to understand: you first check the starting-day-of-the-week (i.e. Sunday) of the first day in April. If the 1st of April is a Monday, the Date.StartOfWeek function will return Sunday 31st March. If the 1st of April is a Tuesday, the Date.StartOfWeek function will return Sunday 30th March. To get the first Sunday you then just use the Date.AddDays function to add 7 days IF the date previously returned was in March (i.e. the 3rd month).&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;FirstSundayInApril&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Month&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddDays&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;FirstSundayInOctober&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Month&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddDays&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, you want to check to see if the current date is between the April and October daylight savings dates.&lt;/p&gt;

&lt;p&gt;If it is between the dates it should be 10 hours ahead of UTC, and if it’s not it should be 11 hours ahead of UTC.&lt;/p&gt;

&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;CurrentDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;From&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LocalNow&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;AustralianTime&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CurrentDate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstSundayInApril&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CurrentDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstSundayInOctober&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LocalNow&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LocalNow&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The full code is below:&lt;/p&gt;
&lt;div class=&quot;language-fsharp highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LocalNow&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;FirstSundayInApril&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Month&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddDays&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;FirstSundayInOctober&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Month&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;AddDays&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StartOfWeek&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CurrentYear&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Sunday&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;CurrentDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;From&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LocalNow&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;),&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;AustralianTime&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CurrentDate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstSundayInApril&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CurrentDate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FirstSundayInOctober&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LocalNow&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;LocalNow&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can also use a variant of this using DateTimeZone.FixedUtcNow and DateTime.AddZone, however in most cases it’s probably not necessary.&lt;/p&gt;

&lt;p&gt;As well as this, most regions will switch to a different timezone at a specific time of the day, such as 1AM or 2AM. For now, I’ll leave this as an exercise for the reader 😊&lt;/p&gt;
</description>
        <pubDate>Sat, 15 Dec 2018 06:25:28 +0000</pubDate>
        <link>https://selfservedbi.com/2018/12/15/converting-from-utc-to-local-timezone-in-power-bi-and-azure-analysis-services/</link>
        <guid isPermaLink="true">https://selfservedbi.com/2018/12/15/converting-from-utc-to-local-timezone-in-power-bi-and-azure-analysis-services/</guid>
      </item>
    
      <item>
        <title>How to automate (Azure) Analysis Services processing from a remote PC</title>
        <description>&lt;p&gt;There are many blog posts showing how to automate processing of a SQL Server Analysis Services model using either the SQL server agent or SSIS.&lt;/p&gt;

&lt;p&gt;There are also many posts out there showing different ways of processing an Azure Analysis Services database through the use of Azure Functions, automation accounts, and runbooks. (&lt;a href=&quot;https://sqldusty.com/2017/06/21/how-to-automate-processing-of-azure-analysis-services-models&quot;&gt;SQLDusty.com&lt;/a&gt;, &lt;a href=&quot;https://blogs.technet.microsoft.com/uktechnet/2018/06/22/how-to-automate-processing-your-azure-analysis-services-models&quot;&gt;technet&lt;/a&gt;, &lt;a href=&quot;https://azure.microsoft.com/en-au/blog/automating-azure-analysis-services-processing-with-azure-functions&quot;&gt;Azure blog&lt;/a&gt;, &lt;a href=&quot;https://docs.microsoft.com/en-us/sql/analysis-services/instances/schedule-ssas-administrative-tasks-with-sql-server-agent?view=sql-server-2017&quot;&gt;official AAS docs&lt;/a&gt;, &lt;a href=&quot;http://byobi.com/2016/11/processing-an-azure-as-database&quot;&gt;byobi.com&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;All of the above require some level of server administration privileges or Azure resource deployment.&lt;/p&gt;

&lt;p&gt;What if you don’t have server admin rights or can’t create Azure resources?&lt;/p&gt;

&lt;p&gt;What if all you’ve got is the “process” rights granted to a role that you belong to?&lt;/p&gt;

&lt;p&gt;If that’s the case, then this post is for you!&lt;/p&gt;

&lt;p&gt;The strategy is relatively simple and uses PowerShell in combination with Task Scheduler.&lt;br /&gt;
You will require:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;administration rights over a local machine in order to enable PowerShell scripting execution&lt;/li&gt;
  &lt;li&gt;an internet connection in order to send the processing command to the server&lt;/li&gt;
  &lt;li&gt;an account with processing rights over the database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are the steps that you need to follow:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Change the execution policy to allow you to execute PowerShell scripts.&lt;/strong&gt; Run the below script as an administrator:&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Set-ExecutionPolicy&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;remotesigned&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;2. Make sure you have the SQLServer PowerShell module installed.&lt;/strong&gt; Information can be found &lt;a href=&quot;https://docs.microsoft.com/en-us/sql/powershell/download-sql-server-ps-module?view=sql-server-2017&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Install-Module&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;SqlServer&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-force&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-allowclobber&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;3. You may now want to test that you can process the database via PowerShell by executing the following code.&lt;/strong&gt; Information can be found &lt;a href=&quot;https://docs.microsoft.com/en-us/powershell/module/sqlserver/invoke-processasdatabase?view=sqlserver-ps&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Invoke-ProcessASDatabase&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Server&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;YourServerName&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-DatabaseName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;YourDatabaseName&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-RefreshType&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;RefreshTypeHere&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here’s an example:&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Invoke-ProcessASDatabase&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Server&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;asazure://region.asazure.windows.net/databaseinstance1&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-DatabaseName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Database1&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-RefreshType&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Full&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You should be prompted for your login credentials, enter the account that has access to process the model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. To automate the script, you should first create an encrypted password for your account.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To do this, execute the script at the end of this step. It will ask you for your username and password credentials.&lt;/p&gt;

&lt;p&gt;Use the credentials for the account that has access to process the database, e.g. domain\username if on SQL Server Analysis Services, or the UPN (i.e. username@domain.com) for Azure Analysis Services.&lt;/p&gt;

&lt;p&gt;The script will then create an encrypted password text file for the account where you ran the code from.&lt;/p&gt;

&lt;p&gt;Make sure you place this encrypted password somewhere that it can be accessed by an unattended account, ideally just in a new folder on the C: drive. For this example I have stored it in C:\Scripts\&lt;/p&gt;

&lt;p&gt;Further information can be found &lt;a href=&quot;https://interworks.com/blog/trhymer/2013/07/08/powershell-how-encrypt-and-store-credentials-securely-use-automation-scripts&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$credential&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Get-Credential&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$credential&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Password&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ConvertFrom-SecureString&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Set-Content&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;c:scriptsencrypted\_password1.txt\&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;5. Next you will want to create the script that processes the model using your credentials (username and encrypted password).&lt;/strong&gt; Again, make sure that your encrypted password file is accessible by an unattended account and is not in any specific user folders. If you run the below script it should execute without any prompts.&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$username&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;username@domain.com&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$encrypted&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Get-Content&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;C:\\Scripts\\scriptsencrypted\_password.txt&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ConvertTo-SecureString&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$cred&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;New-Object&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;System.Management.Automation.PsCredential&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$encrypted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Invoke-ProcessASDatabase&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Server&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;asazure://domain.asazure.windows.net/databaseinstance1&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-DatabaseName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;database1&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-RefreshType&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Full&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Credential&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$cred&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;6. The final step is to configure Task Scheduler to run the script.&lt;/strong&gt; First you should create a new task, name it whatever you want (i.e. Process Analysis Services). Select the user that will have access to run the script, it can be the same account that you’re using to set up this task. You can also select “Run whether user is logged on or not”, and “run with highest privileges”.&lt;/p&gt;

&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/Task-Scheduler-1.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;

&lt;p&gt;Next create a new trigger according to your own required schedule. I’ll leave this for you to work out.&lt;/p&gt;

&lt;p&gt;Finally, create a new action, When creating a new action, you want to run the PowerShell executable, it should be C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&lt;/p&gt;

&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/Task-Scheduler-2.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;

&lt;p&gt;You can test this by opening Run and the path above in and seeing if PowerShell opens.&lt;/p&gt;

&lt;div align=&quot;center&quot;&gt;&lt;img src=&quot;/attachments/Task-Scheduler-3.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;

&lt;p&gt;In the arguments section you should add the -file argument followed by the path to your local PowerShell script. Note that the PowerShell script must be located somewhere that the account can access it from. It is probably best to also put this in your C drive next to your encrypted password file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. After you’ve set up the above, you can test to see if it processes!&lt;/strong&gt; Note that because the task is set to run whether the user is logged on or not, you will not see the PowerShell window open, it will instead run in the background.&lt;/p&gt;

</description>
        <pubDate>Fri, 14 Dec 2018 19:56:47 +0000</pubDate>
        <link>https://selfservedbi.com/2018/12/14/how-to-automate-azure-analysis-services-processing-from-a-remote-pc/</link>
        <guid isPermaLink="true">https://selfservedbi.com/2018/12/14/how-to-automate-azure-analysis-services-processing-from-a-remote-pc/</guid>
      </item>
    
      <item>
        <title>The increasing security requirements of a growing data model</title>
        <description>&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: &lt;em&gt;Power BI Premium has been updated to now include Object Level Security.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In &lt;a href=&quot;/2018/12/11/why-azure-analysis-services-is-a-great-value-proposition/&quot;&gt;my previous post about why I think AAS is a great value proposition&lt;/a&gt;, I mentioned that AAS currently has Object Level Security, whereas Power BI Premium does not.&lt;/p&gt;

&lt;p&gt;I’d like to now expand on this point by explaining why security is an essential part of a growing data model, and why Object Level Security is an important requirement of “larger” data models. (Note: large as in many dimensions and fact tables regardless of the row count).&lt;/p&gt;

&lt;p&gt;I don’t intend to get too technical with this post and only want to provide some basic understanding of why I think OLS is an important feature as a data model matures.&lt;/p&gt;

&lt;h4 id=&quot;the-data-model-development-story&quot;&gt;The data model development story&lt;/h4&gt;

&lt;p&gt;If we think of the typical “grow up” story of a data model, it may first start its life as an embedded model within Excel. At this youthful stage there is no security except for refreshing against the original data sources.&lt;/p&gt;

&lt;p&gt;At first this isn’t a problem because most likely the only person using the data model is you. But it’s also likely that others may want to eventually use your model as well, meaning that they will want either a copy of the model or at least have access to it.&lt;/p&gt;

&lt;p&gt;And why wouldn’t they? The value provided by a data model is huge! Reusable calculations across different dimensions is virtually the ideal form of ad-hoc analysis.&lt;/p&gt;

&lt;p&gt;However, the first gateway-drug into the Microsoft BI ecosystem now rears its head. For others to view your model without compatibility issues, they will need a similar version of Excel, and the best way to consistently achieve this is to use Office 365.&lt;/p&gt;

&lt;p&gt;Many businesses now use Office 365, however, so it’s not really the large hurdle that it once was. For now, let’s continue this thought exercise assuming you’ve got your compatibility issues worked out.&lt;/p&gt;

&lt;p&gt;If or when you later decide to send your Excel workbook to a colleague or external recipient, they will have full access to the tables loaded into the data model, but may not be able to refresh the data (with their ability to refresh determined by the data source security settings). All tables currently loaded into Power Pivot, however, can be extracted.&lt;/p&gt;

&lt;p&gt;One of the first inherent problems of sharing your workbook in this manner (after making sure everyone can open it) is that you can’t all access and edit it at the same time. For example, if it was kept on a network share you would be limited to only one user editing and saving the workbook at a time.&lt;/p&gt;

&lt;p&gt;The interim solution is that you may decide to create copies of the model or to distribute it on a regular basis.&lt;/p&gt;

&lt;p&gt;The problem with creating copies of the model is that whenever you update your local model you’ll need to re-send it to each user, as well as now deal with version control issues.&lt;/p&gt;

&lt;p&gt;While the above problems represent early growing pains, they aren’t necessarily deal breakers.&lt;/p&gt;

&lt;p&gt;The real deal breaker is introduced when you have to develop different variants of the same model for different users depending on their user and security requirements… Bob needs sales data, Sally needs purchasing data, and John the head honcho needs everything.&lt;/p&gt;

&lt;p&gt;Maintaining different models for different users, plus version control, plus the soul destroying inefficiency of recreating or updating the same tables and measures between different models clearly isn’t a sustainable solution. Oh, and did I mention that if your end user doesn’t have access to the data source you’ll need to re-send them an updated workbook with refreshed data on the regular?&lt;/p&gt;

&lt;h4 id=&quot;a-solution-presents-itself&quot;&gt;A solution presents itself&lt;/h4&gt;

&lt;p&gt;Although it’s not so much “present itself” as “parade around in plain sight”.&lt;/p&gt;

&lt;p&gt;Power BI solves the above problems (for a price of $10 USD per person per month) by providing scheduled refresh capabilities, a centralised data model that others can access, and last but not least, role based security.&lt;/p&gt;

&lt;h4 id=&quot;a-word-on-roles&quot;&gt;A word on roles&lt;/h4&gt;

&lt;p&gt;Roles let you define a set of permissions for a group of users. A user may belong to one or more roles.&lt;/p&gt;

&lt;p&gt;In Power BI, roles are limited to only include permissions for Row Level Security (RLS).&lt;/p&gt;

&lt;p&gt;Some quick points on RLS:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;RLS works by defining which rows are available to that role through essentially a custom created filter statement.&lt;/li&gt;
  &lt;li&gt;When you write your filter statement you are granting access to rows, so that if a user belongs to multiple roles they will receive all of the rows granted from all roles combined.&lt;/li&gt;
  &lt;li&gt;New tables added to the model do not get filtered by any roles.&lt;/li&gt;
  &lt;li&gt;RLS only secures row data, it does not secure against metadata such as table or column names.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That last point is important, because it sort of means that the main purpose of RLS is to secure a subset of all rows, not necessarily all of them and to secure against the entire table.&lt;/p&gt;

&lt;p&gt;In larger models it might have been useful if when a table has all rows restricted to a user, the table and all associated measures and columns are hidden as well.&lt;/p&gt;

&lt;p&gt;This is where Object Level Security (OLS) comes in, currently available in Analysis Services as a role permission alongside RLS.&lt;/p&gt;

&lt;p&gt;Some quick notes on OLS:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;OLS works in the user interface by selecting which tables or columns should be hidden from users, however in reality you are granting access to all other tables/columns.&lt;/li&gt;
  &lt;li&gt;If a user belongs to multiple roles, each with OLS settings that grant access to different tables/columns, the “grant” permissions are additive.&lt;/li&gt;
  &lt;li&gt;New tables added to the model are visible to all roles unless the OLS for that role is updated.&lt;/li&gt;
  &lt;li&gt;RLS secures the metadata so that the user cannot see any tables or columns that they don’t have access to, as well as any measures that reference those columns. This is probably why the property name in the underlying model.bim file is called MetadataPermission.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are some &lt;a href=&quot;https://blogs.msdn.microsoft.com/analysisservices/2017/04/19/whats-new-in-sql-server-2017-ctp-2-0-for-analysis-services/&quot;&gt;complications with mixing roles and permission settings&lt;/a&gt;, however my philosophy on using roles currently isn’t affected by this too much.&lt;/p&gt;

&lt;p&gt;So what’s my philosophy on roles? To keep it simple, it’s 1 user per role.&lt;/p&gt;

&lt;p&gt;Why? Well, because working out effective permissions is difficult:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The UI for OLS is unintuitive as it almost implies that you’re denying access instead of granting access, which adds to the difficulty of figuring out effective permissions.&lt;/li&gt;
  &lt;li&gt;Comparing users permissions when the user only belongs to one role is much easier, and is generally how most people approach security access. (e.g. give the new guy the same security as the person they replaced / give everyone on this team the same access).&lt;/li&gt;
  &lt;li&gt;You can then then also decide to name a role after a group of users that it will include.&lt;/li&gt;
  &lt;li&gt;On top of that, I generally prefer to add single users rather than groups of users, just because it reduces the obfuscation even more and means that people aren’t accidentally in more than one group.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;the-maturing-data-model&quot;&gt;The maturing data model&lt;/h4&gt;

&lt;p&gt;Coming back to our maturing data model, you may face growing pains due to the increasing licensing costs of sharing a PBI model to ever increasing numbers of users needing a Pro license, or it could be that you’re starting to get so many tables in your model and don’t like that users can see tables and measures that “for some reason” return blanks when they query their co-worker’s salary information.&lt;/p&gt;

&lt;p&gt;In that case, there’s one more step to find your model a permanent home, and currently it’s to move the model to Analysis Services where OLS can take care of those problems, as well as provide you with a few more fancy features like partitions and perspectives (if you splurge for Enterprise on prem or an “S” instance in Azure).&lt;/p&gt;

&lt;p&gt;Until Power BI Premium receives OLS, Analysis Services provides a compelling reason why it should be a model’s final destination.&lt;/p&gt;
</description>
        <pubDate>Wed, 12 Dec 2018 21:52:30 +0000</pubDate>
        <link>https://selfservedbi.com/2018/12/12/the-increasing-security-requirements-of-a-growing-data-model/</link>
        <guid isPermaLink="true">https://selfservedbi.com/2018/12/12/the-increasing-security-requirements-of-a-growing-data-model/</guid>
      </item>
    
      <item>
        <title>Why Azure Analysis Services is a great value proposition</title>
        <description>&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: after waking up this morning I realized there was just one more item I wanted to add, the suitability of AAS for multi-geo environments, which for many can be a deal breaker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update 2 (18/12/2018)&lt;/strong&gt;: &lt;a href=&quot;https://twitter.com/DOtykier?s=09&quot;&gt;Daniel Otykier&lt;/a&gt; has reminded me of a further important distinction between Power BI Premium and Analysis Services, and that is the ability to use third party tools such as &lt;a href=&quot;https://tabulareditor.github.io/blog.html&quot;&gt;Tabular Editor&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After reading Matthew Roche’s blog post on &lt;a href=&quot;https://ssbipolar.com/2018/12/09/choosing-between-power-bi-premium-and-azure-analysis-services/&quot;&gt;Choosing Between Power BI Premium and Azure Analysis Services&lt;/a&gt; I couldn’t help but feel that Azure Analysis Services (AAS) was coming off second best in a two-person race.&lt;/p&gt;

&lt;p&gt;I know that doesn’t really make sense because whenever these kinds of discussions take place there are lots of disclaimers thrown out saying that choosing the tool should always be based on your specific requirements or what’s right for your environment, and that no single solution fits all scenarios.&lt;/p&gt;

&lt;p&gt;But despite all of that, I still felt the urge to defend AAS as a great no-frills choice (who knew I was so loyal to it?) even though it probably wasn’t even criticized in the first place.&lt;/p&gt;

&lt;p&gt;In fact, I’m almost a little bit nervous posting this because I think if more people “found out” about how great a value proposition AAS is, Microsoft might even have to find a way to make it a less attractive offering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My argument for why AAS is a great value proposition boils down to 3 different factors:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;The licensing and costing is simple, flexible, and &lt;strong&gt;inexpensive&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;It includes all &lt;strong&gt;core functionality&lt;/strong&gt; you would want from a data model.&lt;/li&gt;
  &lt;li&gt;It is highly &lt;strong&gt;accessible&lt;/strong&gt; for data model consumers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Price is a fundamental aspect of assessing value and it follows that one of the main considerations when comparing AAS with Power BI Premium is cost. If we were comparing holiday cruise packages, you can think of AAS as the “standard” package and Power BI Premium as the “all-inclusive” package.&lt;/p&gt;

&lt;p&gt;While both options will get you to where you want to go, Power BI Premium will get you there in a more comfortable manner and include a few more features that you might enjoy along the way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So… let’s talk pricing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An &lt;a href=&quot;https://azure.microsoft.com/en-au/pricing/details/analysis-services/&quot;&gt;S1 instance of AAS&lt;/a&gt; with 100 QPUs and 25GB of RAM will set you back almost $1500 USD per month.&lt;/p&gt;

&lt;p&gt;A &lt;a href=&quot;https://powerbi.microsoft.com/en-us/calculator/&quot;&gt;P1 instance of PBI Premium&lt;/a&gt; with 8 v-cores and 25GB of RAM will set you back $4,995 USD per month.&lt;/p&gt;

&lt;p&gt;I know it’s not an apples-to-apples comparison because PBI Premium includes the ability for end-users to view PBI content within the PBI service without a license (as well as a range of other features), but it’s still interesting to see what you DO get for your S1 instance.&lt;/p&gt;

&lt;p&gt;[And for comparison’s sake, you can also get a B1 instance that costs $313.90 per month, and even a D1 instance that only costs $96.36 (!) per month. That’s an easy point to AAS for pricing flexibility here.]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Core functionality&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What do you get in the “standard” package?&lt;/p&gt;

&lt;p&gt;It turns out you get the important stuff.&lt;/p&gt;

&lt;p&gt;You get a &lt;em&gt;nearly&lt;/em&gt; identical, highly accessible data model that can be published to the cloud and accessed by end users or reports to provide structured or ad-hoc insights.&lt;/p&gt;

&lt;p&gt;In fact, you even get a few things that Power BI Premium doesn’t have yet (although I’m sure it will soon), including but not limited to:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://azure.microsoft.com/en-au/blog/connect-excel-to-an-azure-analysis-services-server/&quot;&gt;Connectivity from Excel in Office 365&lt;/a&gt; without needing to download any extra drivers. No muss, no fuss, and certainly no administrator rights needed. &lt;a href=&quot;https://docs.microsoft.com/en-us/power-bi/service-analyze-in-excel&quot;&gt;The same can’t be said for Power BI&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/azure/analysis-services/tutorials/aas-supplemental-lesson-ragged-hierarchies&quot;&gt;Ragged Hierarchies&lt;/a&gt;. With this relatively simple feature you can create things like hierarchical Active Directory OU container explorers, organization charts, hierarchical profit and loss statements, and more!&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/sql/analysis-services/tabular-models/object-level-security?view=sql-server-2017&quot;&gt;Object Level Security&lt;/a&gt;. With object level security you can secure both entire tables as well as individual columns within your tables. Note, however, that similar-ish security can also be achieved in Power BI through row level security, however you’ll still be showing the end user the name of the table and any columns/measures that should be secured with it. (Also note that this feature and its interaction with row level security can easily cause unintended security access violations/errors if not done carefully. Also, column level security can cause unintended security access violations even if done correctly through the use of trickily written DAX queries, which is probably why it’s not yet in Power BI).&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://azure.microsoft.com/en-au/blog/invite-guest-users-to-your-azure-analysis-services-by-using-b2b/&quot;&gt;Very simple external sharing&lt;/a&gt;. Just invite your end user using their email address. If they have an Office 365 login or a Microsoft account they’ll be authorized, alternatively they’ll just create a guest account and away you go. No additional licensing needed.&lt;/li&gt;
  &lt;li&gt;SQL Server Management Studio, Visual Studio source control, and &lt;a href=&quot;http://bism-normalizer.com/&quot;&gt;BISM Normalizer&lt;/a&gt;. These are the application lifecycle management tools that help you provide a very high quality data model and enable it’s continued improvement and reliability.&lt;/li&gt;
  &lt;li&gt;The ability to deploy your model to one of the many Azure regions around the world, enabling low latency and the highly performant click-clicky-draggy-droppy analysis that Christian Wade so often speaks about. For comparison, Power BI Pro and (I &lt;em&gt;believe)&lt;/em&gt; Premium, while having multi-geo for data compliance reasons, still sends queries through your default tenant region (although I’m sure this will change).&lt;/li&gt;
  &lt;li&gt;Analysis Services also supports third party development tools (I’m thinking of the fantastic &lt;a href=&quot;https://github.com/otykier/TabularEditor/releases/tag/2.7.4&quot;&gt;Tabular Editor&lt;/a&gt;) that can connect directly to the Analysis Services instance (as well as to individual model metadata files or open projects). However, as Daniel mentions in his comment to this post, this will likely go away as XMLA endpoints become available in the coming months.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What are you missing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Of all the features missing, and there are many, the biggest is that your “regular” users can’t view Power BI reports published to the PBI service. The second biggest is the lack of many data source connectors when developing your model, which &lt;em&gt;might&lt;/em&gt; be a deal breaker.&lt;/p&gt;

&lt;p&gt;So how do users interact with this data model if they can’t access the PBI service? How do you get value out of it?&lt;/p&gt;

&lt;p&gt;You might be thinking “you could share Power BI desktop files”, but I’ve always found that very clunky. Plus, it’s sort of the whole reason why the Power BI service exists.&lt;/p&gt;

&lt;p&gt;So no, sharing PBI desktop files isn’t what I was thinking.&lt;/p&gt;

&lt;p&gt;Instead, and perhaps I am naive, but I still believe that even now at the end of 2018, all data eventually makes its way into Excel. (While I love the visualizations within Power BI, the urge to get knee-deep into the numbers using Excel has never gone away, and it’s a credit to the Excel team that their tool is so immensely powerful that there are &lt;a href=&quot;https://www.quora.com/How-many-people-use-Microsoft-Excel&quot;&gt;estimates of over 100 million people using it&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Simply share a workbook that you’ve prepared containing PivotTables, PivotCharts, and cube formulae with someone who has access to the model and you’re done.&lt;/p&gt;

&lt;p&gt;If you have Windows authentication enabled on your AAS server I don’t think the user even gets prompted for credentials when interacting with the data.&lt;/p&gt;

&lt;p&gt;The whole experience is just so easy, so seamless, and there’s so little time spent on licensing scenarios or access control. I find that this solution works very well for small to medium sized teams. Even for sharing with external auditors or consultants this kind of solution can be highly (cost-) effective.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Closing remarks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;…and we’ve come full circle, I’ve just realized I’m making a recommendation assuming that you, the reader, might be in a specific scenario where the value you’ll get from AAS is particularly high. I guess it really does all depend on your requirements and current environment.&lt;/p&gt;

&lt;p&gt;I hope you got something out of this article. It’s at least made me realize that I really do think Power BI Premium is (soon-to-be) fantastic, and if you can afford it, all the more power to you! But even without Premium, don’t underestimate how effective an Analysis Services tabular model in Azure can be (when paired with Excel).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you notice any errors or inaccuracies please let me know and I’ll make any amendments as necessary.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Added reference:&lt;/strong&gt; For a more detailed comparison between the different variants of Analysis Services and Power BI, Paul Turley has &lt;a href=&quot;https://sqlserverbi.blog/2018/12/13/data-model-options-for-power-bi-solutions/&quot;&gt;a great blog post&lt;/a&gt; where he makes direct feature comparisons in a table format.&lt;/p&gt;
</description>
        <pubDate>Tue, 11 Dec 2018 07:16:53 +0000</pubDate>
        <link>https://selfservedbi.com/2018/12/11/why-azure-analysis-services-is-a-great-value-proposition/</link>
        <guid isPermaLink="true">https://selfservedbi.com/2018/12/11/why-azure-analysis-services-is-a-great-value-proposition/</guid>
      </item>
    
  </channel>
</rss>
