<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://community.altiusconsulting.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Jake Smillie</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Dealing with large and small SCD dimensions flexibly</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2011/04/12/dealing-with-large-and-small-scd-dimensions-flexibly.aspx</link><pubDate>Tue, 12 Apr 2011 11:09:58 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:632</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>15</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=632</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2011/04/12/dealing-with-large-and-small-scd-dimensions-flexibly.aspx#comments</comments><description>&lt;p&gt;How many times have you been sat with a customer explaining the differences between a Type-1 and Type-2 attribute? In many cases they are unsure – at least in the requirements gathering phase - how they want to deal with certain attributes in both their Data Warehouse and any reporting they conduct off of that. Indeed they may also want to track the changes in the warehouse, but not show them as changes in reports. &lt;/p&gt;  &lt;p&gt;The customers may say, ‘no I don’t care about the history’ and then 2 months later wonder why they cannot see ‘what was’. &lt;/p&gt;  &lt;p&gt;As experts, it is our job to ‘know best’ from our experience and model their data structures that provide flexibility for users, so when they change their mind and say to you ‘why can’t I see what was’ we can look smug and say… ‘you can’. Also, on the flip side, your customer might get worried about dismissing data and say they want to keep history of everything without thought, as they do not want to commit to losing any data. You know that some attributes will not require history in reports e.g. ‘Customer First Name’, but the customer wanted to keep everything, so that is what we do.&lt;/p&gt;  &lt;p&gt;So, to model dimensions both large and small where you think you might want to change your mind if attributes are Type-1 or Type-2 you can do so in the following way.&lt;/p&gt;  &lt;p&gt;I am going to use a simple products dimension to demonstrate how to do this with the following attributes:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_12880F9F.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_5F4BD635.png" width="155" height="109" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So, with initial discussions with the business they have said to you that RRP is a Type-2 attribute and the rest are Type-1. Fair enough.&lt;/p&gt;  &lt;p&gt;However, your experience tells you that if a product changes department, the business may not want to attribute historic sales of that product to its new department as it will skew the historical performance, so you have the foresight to make it flexible, to enable the customer to change their mind at a later date. &lt;/p&gt;  &lt;p&gt;So, to do this I have 2 tables for my dimensions. One for the current record and one for the history.&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_45E3D2FB.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_4577A006.png" width="597" height="286" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;p&gt;The purposes of these tables are as follows&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Dim_Product_Current&lt;/strong&gt; – holds the current record attributes of the product. There is only one version for each product.&lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Dim_Product_History&lt;/strong&gt; – holds every version and tracks changes on all attributes Type-1 and Type-2 creating the surrogate keys and RowStart and RowEnd dates along they way. NB. It is optional to track changes on Type-1 as well as Type-2 attributes if you are sure that the the attributes are, and will always be Type-1. Additionally, you will have to be careful on how you design your dimensions such that you do not create many more changes than is necessary. e.g. if a Type-1 attribute changes every day, then you will need to think a different way to model that attribute such that your dimension history table will not balloon fast, but that also applies to normal Type-2s as well.&lt;/p&gt;    &lt;p&gt;As a side, I like to keep information in my dimension that tells me whether or not the record has been inferred by an early arriving fact and I like to hold the first introduced date (i.e. the first time the record was seen by the data warehouse).&lt;/p&gt;    &lt;p&gt;So, to load this data, the following work flow should take place.&lt;/p&gt;    &lt;div id="codeSnippetWrapper"&gt;     &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;       &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;each&lt;/span&gt; newOrChangedRecord&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    compare &lt;span style="color:#0000ff;"&gt;to&lt;/span&gt;  Dim_Products_Current&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;then&lt;/span&gt; &lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;            add &lt;span style="color:#0000ff;"&gt;to&lt;/span&gt; Dim_Products_History &lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;            add &lt;span style="color:#0000ff;"&gt;to&lt;/span&gt; Dim_Products_Current&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt;&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; type_2  &lt;span style="color:#0000ff;"&gt;then&lt;/span&gt; &lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;            &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt; currentRow &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Dim_Products_History&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;            add newVersionRow &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Dim_Products_History&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;            update row &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Dim_Products_Current&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt;&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; type_1 &lt;span style="color:#0000ff;"&gt;then&lt;/span&gt;&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;            &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt; currentRow &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Dim_Products_History &lt;span style="color:#008000;"&gt;&amp;#39; optional if tracking all changes &amp;#39;&lt;/span&gt;&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;            add newVersionRow &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Dim_Products_History &lt;span style="color:#008000;"&gt;&amp;#39; optional again - as above &amp;#39;&lt;/span&gt;&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;            update row &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Dim_Products_Current&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt;&lt;/pre&gt;


      &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;loop&lt;/pre&gt;
&lt;/div&gt;
  &lt;/div&gt;
&lt;/p&gt;

&lt;p&gt;The SSIS version of this is shown below.&lt;/p&gt;

&lt;p&gt;First we find all the changes that have happened and stage them into a Dim_Products_SCD table marking them wit the type of change, New_Row, Type_1 or Type_2.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_5E073D56.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_7DB6171E.png" width="504" height="567" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then we use set based updates and inserts to handle the changes in both Dim_Products_Current and Dim_Products_History.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_3660C12C.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_6B011D67.png" width="512" height="332" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, lets see what this does. If we consider the following table of original rows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_0EBA4502.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_755241C7.png" width="469" height="219" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, once this has passed through the ETL for the first time, we should see 10 rows in both, Dim_Products_Current and Dim_Products_History.&lt;/p&gt;

&lt;p&gt;and alas, we do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dim_Products_History&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_69BC8488.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_7479DBDD.png" width="766" height="172" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dim_Products_Current&lt;/strong&gt;&lt;/p&gt;







&lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_1ADBBF29.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_485CDEEC.png" width="605" height="201" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All sales from this point forward will map to the surrogate Product_Key in the Dim_Products_History.&lt;/p&gt;

&lt;p&gt;So now, if we make some changes.&lt;/p&gt;

&lt;p&gt; new Product 4545: NewProduct in Produce at 5.00&lt;/p&gt;

&lt;p&gt; change the currently type-2 attribute RRP of Pinot Grigio to 5.99 – 2.30 was too much of a bargain&lt;/p&gt;

&lt;p&gt; change the currently type-1 attribute of Department of crisps to BWS as we think they may sell better with the beers.&lt;/p&gt;

&lt;p&gt;So the new source looks as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_010788FA.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_074E5F88.png" width="633" height="83" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, after running the ETL, we expect to see 3 new rows in the Dim_Products_History and 1 new row in the Dim_Products_Current – for the new product.&lt;/p&gt;

&lt;p&gt;Alas we do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dim_Products_History&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_7FC2F01A.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_5F3BB068.png" width="761" height="225" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dim_Products_Current&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_70AC1140.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_2956BB4E.png" width="602" height="261" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, all crisps, and Pinot Grigio sold after 2010-05-04 will get the new surrogate keys in the fact 11 and 12 respectively. Well, that’s all great, but it is confusing to the users and report writers of the warehouse to have 2 tables. Well, to get round this we can create a view warehouse.Dim_Products and, because we can turn Type-1 and Type-2s on and off as we please, without having to re-load facts, suddenly our dimension is very powerful indeed.&lt;/p&gt;

&lt;p&gt;So, consider the following view.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;alter&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;view&lt;/span&gt; [warehouse].[Dim_Products] &lt;span style="color:#0000ff;"&gt;with&lt;/span&gt; schemabinding&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;as&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;select&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       hist.[Product_Key]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,cur.[Product_Business_Key]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,cur.[Product_Name] &lt;span style="color:#008000;"&gt;/* I can turn on and off my type1 or type2s */&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,cur.[Department]   &lt;span style="color:#008000;"&gt;/* I can turn on and off my type1 or type2s */&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,cur.[Department_Name]  &lt;span style="color:#008000;"&gt;/* I can turn on and off my type1 or type2s */&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[RRP]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[RowStartDate]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[RowEndDate]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[FirstIntroducedDate]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[RowIsCurrent]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[Inferred]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[Type_2_Checksum]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[Type_1_Checksum]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;from&lt;/span&gt; [warehouse].[Dim_Products_Current] cur&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;inner&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;join&lt;/span&gt; [warehouse].[Dim_Products_History] hist&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;on&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    cur.Product_Business_Key = hist.Product_Business_Key &lt;/pre&gt;
&lt;/div&gt;
This results in the following&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_4FB89E99.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_6EFB456C.png" width="654" height="226" /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;So you can see that Crisps has moved to BWS for all history (Type-1) and RRP has changed (Type-2) for Pinot Grigio. Now I want department to Type-2 as the customer has decided to change their mind. No problem. All the fact keys have got their correct surrogate key, all I need to do is change the view!&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;alter&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;view&lt;/span&gt; [warehouse].[Dim_Products] &lt;span style="color:#0000ff;"&gt;with&lt;/span&gt; schemabinding&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;as&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&amp;#160;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;select&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;       hist.[Product_Key]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,cur.[Product_Business_Key]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,cur.[Product_Name] &lt;span style="color:#008000;"&gt;/* I can turn on and off my type1 or type2s */&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[Department]  &lt;span style="color:#008000;"&gt;/* I have changed this row */&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[Department_Name]  &lt;span style="color:#008000;"&gt;/* I changed this row */&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[RRP]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[RowStartDate]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[RowEndDate]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[FirstIntroducedDate]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[RowIsCurrent]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[Inferred]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[Type_2_Checksum]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;      ,hist.[Type_1_Checksum]&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;from&lt;/span&gt; [warehouse].[Dim_Products_Current] cur&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;inner&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;join&lt;/span&gt; [warehouse].[Dim_Products_History] hist&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;on&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    cur.Product_Business_Key = hist.Product_Business_Key &lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div&gt;This very small change has the ability to change the whole rules of Department for the whole dimension.&lt;/div&gt;

&lt;div&gt;&amp;#160;&lt;/div&gt;

&lt;div&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_434A7B70.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_6703A30A.png" width="644" height="217" /&gt;&lt;/a&gt;&lt;/div&gt;





&lt;p&gt;As you can see, Department now acts like a Type-2 dimension. So not only can we change the behaviour of our dimension, we can create more views with our desired behaviour for any Data Marts the business requires. This approach also works well for large dimensions as we do not have to change all versions of records for Type-1 changes which can be expensive updates. All we need to do is update the row in Dim_Product_Current.&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=632" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Data+Warehousing/default.aspx">Data Warehousing</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Kimball/default.aspx">Kimball</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Finding previous or next row using T-SQL Faster</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2011/04/11/finding-previous-or-next-row-using-t-sql-faster.aspx</link><pubDate>Mon, 11 Apr 2011 17:08:57 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:631</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=631</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2011/04/11/finding-previous-or-next-row-using-t-sql-faster.aspx#comments</comments><description>&lt;p&gt;In many cases, it can be required to find the previous or next row within a table. For instance, when wanting to find out the previous date ‘something’ happened or the previous version of a record.&lt;/p&gt;  &lt;p&gt;I am going to show you two different ways to do this, one that performs better than the next.&lt;/p&gt;  &lt;p&gt;Consider the following date table from AdventureWorksDW&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_216639D1.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_47C81D1C.png" width="420" height="202" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It may be useful, for a date, to find the previous date. A common business problem that may require this, is in a financial services system where we need to know how many days interest has accrued for. &lt;/p&gt;  &lt;p&gt;So the output we are after is something as follows:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_0072C72A.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_4E0EF3AA.png" width="425" height="144" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As you can see we have the DateKey along with the previous date key: PrevDate.&lt;/p&gt;  &lt;p&gt;To get this, many will use the following SQL&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;statistics&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;time&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;off&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;statistics&lt;/span&gt; io &lt;span style="color:#0000ff;"&gt;off&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;DBCC&lt;/span&gt; DROPCLEANBUFFERS&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;DBCC&lt;/span&gt; FREEPROCCACHE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;statistics&lt;/span&gt; io &lt;span style="color:#0000ff;"&gt;on&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;statistics&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;time&lt;/span&gt; on&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;select&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    prev.PrevDate,&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    prev.PrevFullDateAlternateKey,&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    d.DateKey,&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    Datediff(&lt;span style="color:#0000ff;"&gt;day&lt;/span&gt;, prev.PrevFullDateAlternateKey, d.FullDateAlternateKey) &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; DaysInterestAccrued&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;from&lt;/span&gt; dbo.DimDate d&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;inner&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;join&lt;/span&gt; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;(&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;select&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        d.DateKey,&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;MAX&lt;/span&gt;(p.DateKey) PrevDate,&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;MAX&lt;/span&gt;(p.FullDateAlternateKey) &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; PrevFullDateAlternateKey&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;from&lt;/span&gt; dbo.DimDate d&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;left&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;outer&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;join&lt;/span&gt; dbo.DimDate p&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;on&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        d.DateKey &amp;gt; p.DateKey&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;group&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;by&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        d.DateKey&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;) prev&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;on&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    d.DateKey = prev.DateKey&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;&lt;font face="Courier New"&gt;Table &amp;#39;DimDate&amp;#39;. Scan count 1190, logical reads 13934, physical reads 2, read-ahead reads 19, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font face="Courier New"&gt;SQL Server Execution Times:
    &lt;br /&gt;&amp;#160; CPU time = 468 ms,&amp;#160; elapsed time = 682 ms.

    &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;So here, in the inner select we are finding the previous date for each date. We then join on this inner select to find the details we require.&lt;/p&gt;

&lt;p&gt;Another way to achieve identical results is to use cross apply &lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;statistics&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;time&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;off&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;statistics&lt;/span&gt; io &lt;span style="color:#0000ff;"&gt;off&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;DBCC&lt;/span&gt; DROPCLEANBUFFERS&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;DBCC&lt;/span&gt; FREEPROCCACHE&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;statistics&lt;/span&gt; io &lt;span style="color:#0000ff;"&gt;on&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;set&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;statistics&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;time&lt;/span&gt; on&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;select&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    prev.PrevDate,&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    prev.PrevFullDateAlternateKey,&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    d.DateKey,&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    Datediff(&lt;span style="color:#0000ff;"&gt;day&lt;/span&gt;, prev.PrevFullDateAlternateKey, d.FullDateAlternateKey) &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; DaysInterestAccrued&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;from&lt;/span&gt; dbo.DimDate d&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#0000ff;"&gt;cross&lt;/span&gt; apply&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;(&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;select&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;MAX&lt;/span&gt;(prev.DateKey) PrevDate,&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        &lt;span style="color:#0000ff;"&gt;MAX&lt;/span&gt;(prev.FullDateAlternateKey) &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; PrevFullDateAlternateKey&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;from&lt;/span&gt; dbo.DimDate prev&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;    &lt;span style="color:#0000ff;"&gt;where&lt;/span&gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;        d.DateKey &amp;gt; prev.DateKey&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;) prev&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;font face="Courier New"&gt;Table &amp;#39;DimDate&amp;#39;. Scan count 2377, logical reads 5567, physical reads 5, read-ahead reads 8, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font face="Courier New"&gt;SQL Server Execution Times:
    &lt;br /&gt;&amp;#160;&amp;#160; CPU time = 47 ms,&amp;#160; elapsed time = 234 ms.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;For the dataset I am using in AdventureWorksDW, the cross apply version of this code reduced the execution time by about half due to both having to do less logical reads and to not having to do expensive Nested Loop joins on the the full dataset within DimDate in the sub select.&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=631" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>UK OUG  &amp; Shared Services Security</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2010/03/18/uk-oug-amp-shared-services-security.aspx</link><pubDate>Thu, 18 Mar 2010 17:35:00 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:467</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=467</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2010/03/18/uk-oug-amp-shared-services-security.aspx#comments</comments><description>&lt;p&gt;This week I attended and presented at my first UK Oracle User Group, Special Interest Group (SIG) for Essbase and Planning. Attending the UK OUG was definitely beneficial and great to find out what other people are doing with the products. I would thoroughly recommend this to anyone who has an interest in Essbase and Planning to attend these events. You can join the UK OUG by signing up &lt;a href="http://www.ukoug.org/"&gt;http://www.ukoug.org/&lt;/a&gt; and you should.&lt;/p&gt;  &lt;p&gt;As I said I also presented a piece on Hyperion Shared Services 11.1.1.3 with tips and tricks on how to setup security and why you should use it. To see the slides please join UK OUG and go &lt;a href="http://www.ukoug.org/lib/show_document.jsp?id=11565"&gt;http://www.ukoug.org/lib/show_document.jsp?id=11565&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Enjoy, and I hope to see you at future UK OUG meetings!&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=467" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Essbase/default.aspx">Essbase</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Shared+Services/default.aspx">Shared Services</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/UK+OUG/default.aspx">UK OUG</category></item><item><title>Modelling &amp; Loading a Slowly Changing Many-to-Many Relationship</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2010/02/18/modelling-amp-loading-a-slowly-changing-many-to-many-relationship.aspx</link><pubDate>Thu, 18 Feb 2010 13:56:31 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:442</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=442</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2010/02/18/modelling-amp-loading-a-slowly-changing-many-to-many-relationship.aspx#comments</comments><description>&lt;p&gt;I haven’t blogged for a while, mostly because I have been busy. Today I am on a train to London , so I thought what better thing could I do to fill the time than to blog about something I have been meaning to blog about for a while: Modelling Slowly changing many-to-many relationships in a Data Warehouse.&lt;/p&gt;  &lt;p&gt;This is something that, on paper, seems easy, but also very easy to get wrong / fall into common pitfalls.&lt;/p&gt;  &lt;p&gt;When I was first asked to model such a scenario I went looking in text books and Google (or do I mean Bing now?). Anyway, I was shocked to see a distinct lack of information about this or at least no information that went into enough detail. So here is my in detail explanation on how to do this.&lt;/p&gt;  &lt;p&gt;Consider the scenario where you have products and groups of products. A product can belong to many groups and they can also move in and out of groups, but we want to measure sales at any given time for these groups. Your Products dimension can slowly change, as can your ProductGroups, as can your ProductGroup_Mappings!&lt;/p&gt;  &lt;p&gt;Below are extracts of an example Product, ProductGroup dimensions and a Sales Fact Extract.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_15989F54.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_7BC46924.png" width="588" height="135" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_1B7342ED.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_5B3D2972.png" width="597" height="105" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_25C4674D.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_2C7770D0.png" width="528" height="194" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Group 1 has Product A up until 20th-Feb-2009 and has Product B always. So if we wanted to get the Sum of all sales for Group 1 we would get 5(Transactions 1,2,4,5,6). We would not include 3 because this sold product A when it was not part of Group 1 (after 20th-Feb-2009).&lt;/p&gt;  &lt;p&gt;To model this in a Data Warehouse, you may initially do it like the following:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Linked on Business Keys&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image16_7FB57D55.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image16_thumb_38602763.png" width="604" height="74" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So from the above you can see after 20th-Feb-2009 Product A is no longer part of group 1. This would be fine, and work if you are using SQL to retrieve data because you can add some between clauses using the RowStart and End dates etc when doing a retrieval to find total sales for Group 1, but for me, this is missing the point of a Data Warehouse. Querying a well designed Data Warehouse should be simple, I don’t want to have to worry about complex where clauses to get the data I want. It should all just work! Besides if you had an OLAP engine such as SSAS on top of your Data Warehouse it would not know what to do with RowStart and End Dates.You need to be able to write queries by just using simple joins without where clauses on RowStart and End dates to do things like this. The best way to think about this is VLOOKUPS in Excel. SSAS will in essence do VLOOKUPS from your fact to your dimension to get the correct dimension member.&lt;/p&gt;  &lt;p&gt;So let’s see how this would aggregate all sales for Group 1.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_4AE1B1B9.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_23A76884.png" width="797" height="126" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So what’s happening here?:&lt;/p&gt;  &lt;p&gt;First find all products in Grp1 (I used a VLOOKUP for this: Matches twice and return Products A &amp;amp; B. &lt;/p&gt;  &lt;p&gt;Then:&lt;/p&gt;  &lt;p&gt;(sum all sales where Product = A) + (sum all sales where Product = B): I used SUMPRODUCT for this&lt;/p&gt;  &lt;p&gt;As you can see it has matched on all sales for Product A which is wrong. We want it to exclude transaction 3 as it happened when Product A was not in Group 1.&lt;/p&gt;  &lt;p&gt;This approach on joining on business keys works fine for groups that do not slowly change. E.g. You add a product to a group and all sales of that product are attributed to that group. You then remove it and none are attributed to that group. &lt;/p&gt;  &lt;p&gt;Ah… I need to do the relationship on surrogate keys. After all this is why we have them in slowly changing dimensions!&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Linked on Surrogate Keys&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Product Dimension for reference:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_15989F54.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_7BC46924.png" width="588" height="135" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_5847C4BF.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_032028D2.png" width="815" height="119" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now we see and extra row (2) due to the slow change of product A. Now lets see what happens when we link on keys to the sales.&lt;/p&gt;  &lt;p&gt;Sales data for reference:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_25C4674D.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_2C7770D0.png" width="528" height="194" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_09D33255.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_29820C1D.png" width="804" height="141" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So again, we first get the product keys that are attributed to Group 1: (P1,P2 &amp;amp; P3) and we then aggregate all sales where those are the keys for.&lt;/p&gt;  &lt;p&gt;Bingo! We have the right answer. Modelling on surrogate keys is definitely the way forward. But is that it? The more astute of you will realise that this has the exact same problem as the Business Key modelling. If we had a sale of Product A on the 22-Feb-2009, after Product A has been removed from group 1 but before it slowly changed itself (on 01-Mar-2009) the join would include that sale, wouldn’t it?&lt;/p&gt;  &lt;p&gt;Well lets see…&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_0F41A2F9.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_074A0097.png" width="533" height="209" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Transaction 7 is the new transaction.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_0CB8713B.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_64A5C21B.png" width="831" height="135" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Well yes our suspicions are correct it does break!&lt;/p&gt;  &lt;p&gt;What this means is that if any change to a group happens (add a remove a product to it) we need to slowly change the products in the ETL or ELT process before any sales data (or any fact data) comes through. So lets see what the new Product dimension looks like when this happens.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_2B22B224.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_0A9B7272.png" width="667" height="181" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;There is a new product key for product A which starts on the 20th-Feb-2009 (when Product A is removed from Group1) and then again for P5 is the normal slow change on 01-Mar-2009. This makes the sales fact look like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/image_5371E478.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_2035AB0F.png" width="824" height="141" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Now it definitely works. Good stuff.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;- You need to model such scenarios using surrogate keys and not business ones&lt;/p&gt;  &lt;p&gt;- Every time the members of a group change you need to force a change on the affected dimensions. This process makes the loading of the warehouse complex especially when you have multiples of these relationships and they change frequently, but who said loading Data Warehouses was easy?&lt;/p&gt;  &lt;p&gt;There is one other way to do this relationship without having to force the change of the members and that is to include the date key in the many-to-many mapping. Whilst this would work, it could have a detrimental affect on performance as you could quickly have millions of rows in your mapping table / bursting view (if you join on dates dimension).&lt;/p&gt;  &lt;p&gt;Finally I have attached my Excel spreadsheet of my working so you can have a play. Enjoy! &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:3d34d2a7-db72-406a-810f-eca9ea76eeac" class="wlWriterEditableSmartContent"&gt;&lt;p&gt;&lt;div&gt;&lt;a href="http://community.altiusconsulting.com/blogs/jakesmillie/ManyToManyModelling_261760A1.xls" target="_blank"&gt;ManyToManyModelling.xls&lt;/a&gt;&lt;/div&gt;&lt;/p&gt;&lt;/div&gt;  &lt;p&gt;Jake&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=442" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/ETL/default.aspx">ETL</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Data+Warehousing/default.aspx">Data Warehousing</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Kimball/default.aspx">Kimball</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SSAS/default.aspx">SSAS</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Design+Tips/default.aspx">Design Tips</category></item><item><title>SmartView – Timeout Increase NetRetryCount</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2009/11/02/smart-view-timeout-increase-netretrycount.aspx</link><pubDate>Mon, 02 Nov 2009 12:44:00 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:378</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=378</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2009/11/02/smart-view-timeout-increase-netretrycount.aspx#comments</comments><description>&lt;p&gt;Recently I have been tearing my hair out with SmartView as whenever I perform a large query against my Essbase cube I receive a timeout that suggests I should up the NetRetryCount. &lt;/p&gt;  &lt;p&gt;“Fine” I thought, so I updated the Essbase.cfg file with the following (just to be sure):&lt;/p&gt;  &lt;p&gt;NETDELAY 8000   &lt;br /&gt;NETRETRYCOUNT 8000&lt;/p&gt;  &lt;p&gt; and restarted Essbase and re-tried my query.&lt;/p&gt;  &lt;p&gt;Same Error! That config change seems to have done nothing.&lt;/p&gt;  &lt;p&gt;A little hunting around later, I discovered there was another setting I need to change (in APS essbase.properties file). Of course! I am connecting through provider services to connect to Essase. It is APS that is timing out. So I update essbase.properties to:&lt;/p&gt;  &lt;p&gt;olap.server.netConnectRetry=8000   &lt;br /&gt;olap.server.netDelay=8000    &lt;br /&gt;olap.server.netSocketTimeOut=800&lt;/p&gt;  &lt;p&gt;restarted Provider Services (and Essbase for good measure) and re-tried my query.&lt;/p&gt;  &lt;p&gt;Grrr! Same error! What is going on?&lt;/p&gt;  &lt;p&gt;Some more hunting around and reading endless posts of making sure you restart the services after changing the config settings I stumbled across this forum &lt;a href="http://www.network54.com/Forum/58296/message/1212599342/Hyperion+figured+out+my+issue"&gt;http://www.network54.com/Forum/58296/message/1212599342/Hyperion+figured+out+my+issue&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It seems Internet Explorer has a default timeout, and it seems that SmartView uses these settings:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://support.microsoft.com/kb/813827"&gt;http://support.microsoft.com/kb/813827&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://support.microsoft.com/kb/181050"&gt;http://support.microsoft.com/kb/181050&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;IE 6 has a default of timeout of 60 seconds and 7 has a default of 30 seconds. I added the following registry settings&lt;/p&gt;  &lt;p&gt;[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]&lt;/p&gt;  &lt;p&gt;&amp;quot;ReceiveTimeout&amp;quot;=dword:00075300&lt;/p&gt;  &lt;p&gt;&amp;quot;KeepAliveTimeout&amp;quot;=dword:000493e0&lt;/p&gt;  &lt;p&gt;&amp;quot;ServerInfoTimeout&amp;quot;=dword:000493e0&lt;/p&gt;  &lt;p&gt;Where 000493e0 = 5 minutes and 00075300 = 8 minutes. &lt;/p&gt;  &lt;p&gt;I restarted Excel and I no longer received the timeout Increase NetRetryCount issue. I will now include this in any install I do of SmartView&lt;/p&gt;  &lt;p&gt;I hope this helps someone else. I feel your pain!&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=378" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Hyperion/default.aspx">Hyperion</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Essbase/default.aspx">Essbase</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Oracle/default.aspx">Oracle</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SmartView/default.aspx">SmartView</category></item><item><title>Importance of Unrealised FX Gain and Loss</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2009/08/07/importance-of-unrealised-fx-gain-and-loss.aspx</link><pubDate>Fri, 07 Aug 2009 05:18:41 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:318</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=318</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2009/08/07/importance-of-unrealised-fx-gain-and-loss.aspx#comments</comments><description>&lt;p&gt;Many businesses want to see measures across multiple currencies, for example: sales for all countries or customer balances for all account currency types. Typically when dealing with multiple currencies a ‘base’ currency to report on is chosen to make life easier (you can’t simply add Euro sale values to Sterling sale values and get the correct total sales answer). This means data needs to be converted to base currency so we can accurately see how we are doing. &lt;/p&gt;  &lt;p&gt;Currency exchange rates are by no means static, so movement in exchange rates can influence your measures.&lt;/p&gt;  &lt;p&gt;For example, if you wanted to see total balances across months you might see something like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_02FBF0B4.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_2166319D.png" width="643" height="350" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Looking at this we can see that May 2009 was a great month!…. Or was it?&lt;/p&gt;  &lt;p&gt;Well lets look at the raw data that makes this chart.&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_306CEAAA.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_1383C5D5.png" width="488" height="232" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;You can see in May 2009 we actually lost €100,000. The above report paints a very different picture to what actually happened! The reason why the chart shows such a large jump is that Sterling became a lot stronger against the Euro giving the illusion of a good month, when really it wasn’t.&lt;/p&gt;  &lt;p&gt;This means we have to track Unrealised FX Gain and Loss to understand the numbers better.&lt;/p&gt;  &lt;p&gt;Depending on whether you are using ‘End of Day’ or ‘Start of Day’ exchange rates this is done differently.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;End of Day Rate&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To calculate unrealised FX using end of day rates use this formula:&lt;/p&gt;  &lt;p&gt;(Today’s Measure @ Today’s Exchange Rate) - (Today’s Measure @ Previous Exchange Rate)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Start of Day Rate&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To calculate unrealised FX using start of day rates use this formula (rates should be in direct quotation e.g. local ccy value * rate = base ccy value)&lt;/p&gt;  &lt;p&gt;(Today’s Measure - (measure delta)) * (exchange rate delta)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Once unrealised FX is calculated we can show a slightly different report:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_06A96FB7.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_0C841350.png" width="649" height="144" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We will use the Balance £ – Unrealised FX Accumulation to display in our report, which gives us:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_7D010180.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_14B838E7.png" width="692" height="379" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;This shows something quite different from the report above, but it shows a more accurate visualisation of the numbers. It shows that May 2009 was actually a bad month.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now that you understand the importance of tracking Unrealised FX you need to decide at what granularity to track it. I would recommend tracking it at the lowest level possible so that you can see it at any aggregation level. This makes your design a little more tricky but gets you the most flexibility.&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=318" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Reporting/default.aspx">Reporting</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Data+Warehousing/default.aspx">Data Warehousing</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Design+Tips/default.aspx">Design Tips</category></item><item><title>Multi Level Hierarchy Dimension Design Tip</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2009/08/07/multi-level-hierarchy-dimension-design-tip.aspx</link><pubDate>Fri, 07 Aug 2009 03:34:16 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:317</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=317</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2009/08/07/multi-level-hierarchy-dimension-design-tip.aspx#comments</comments><description>&lt;p&gt;When building a dimensional modelling solution, somewhere along the line you will almost certainly have at least one multi level hierarchy within one or more dimensions. A good example of this is a Product hierarchy, which might go:&lt;/p&gt;  &lt;p&gt;Department-&amp;gt;Sub Department-&amp;gt;Type-&amp;gt;Product&lt;/p&gt;  &lt;p&gt;Typically for each level member you will have an ID (be it numeric or alpha numeric) and a Description. In the Adventure Works database there is a product hierarchy that goes: Department-&amp;gt;Sub Department-&amp;gt;Model-&amp;gt;Product, so this seems like a nice example to share this tip.&lt;/p&gt;  &lt;p&gt;Lets have a look at how you might store this data in your conformed dimension:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_25E2EFAD.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_360EB7A6.png" width="693" height="135" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So here, Product 709 rolls into Mountain Bike Socks, Socks and Clothing.&lt;/p&gt;  &lt;p&gt;Building this in a cube is simple, but sometimes not all reports are suited to cube and are better delivered using SQL. &lt;/p&gt;  &lt;p&gt;Lets consider a requirement whereby the user wants a dump of all sales between dates and wants to filter by any level in the Product hierarchy (e.g. any Clothing, or just Socks).&lt;/p&gt;  &lt;p&gt;There are many ways to provide this solution but there is 1 way I like.&lt;/p&gt;  &lt;p&gt;Assuming that you would do this in a stored procedure, you might pass in each level ID for Category, Subcategory, Model and Product as a parameter and then determine what to filter on based on their selection (e.g. If they selection ‘All’ for Subcategory do not filter on this and so on. Doing this is complicated and gives me a headache, you might use 4 different almost identical SQL statements and have IF (SubcategoryIDSelection = ‘All’) then run this query, otherwise run another query. Confused? I am. You may use dynamic SQL to build up the query (which is a nightmare to maintain / understand what is going on). &lt;/p&gt;  &lt;p&gt;The way I like to do achieve this is to store a unique hierarchy key as a string for each product. So for Product 709 we would have: ‘0003_0023_000013_000709’ as the ProductHierarchyKey (we pad the keys to make them sortable). This makes filtering on any level of the hierarchy very easy. For example if the user requests to see all sales for Clothing_Socks we pass into the procedure ‘0003_0023’ as the value we can then do a select and filter like this:&lt;/p&gt;  &lt;div&gt;   &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:27.76%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;height:93px;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;SELECT&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt;     p.*&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;FROM&lt;/span&gt; dbo.D_Product p&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;WHERE&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;     p.ProductHierarchyCode &lt;span style="color:#0000ff;"&gt;like&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;#39;0003_0023%&amp;#39;&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Which will bring back products 709 and 710. As you can see, it doesn’t matter what level you pass into the procedure, it will always be the same query (no need to build any funky logic or use dynamic SQL). It also makes it easier to filter on multiple selections, e.g. the user might want to see sales for ‘Socks’ and ‘Road Frames’ together. So we would pass in ‘0003_0023,0002_0014’ then split the parameter by ‘,’ into a table variable (I will let you decide how to do this as there are many techniques) and then execute SQL similar to:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:27.32%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;height:109px;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;SELECT&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt;     p.*&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;FROM&lt;/span&gt; dbo.D_Product p&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;INNER&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;JOIN&lt;/span&gt; @SelectedProducts sel&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;ON&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;     p.ProductHierarchyCode &lt;span style="color:#0000ff;"&gt;like&lt;/span&gt; sel.&lt;span style="color:#0000ff;"&gt;Value&lt;/span&gt; + &lt;span style="color:#006080;"&gt;&amp;#39;%&amp;#39;&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This approach, for me, is far simpler and easier to understand.&lt;/p&gt;

&lt;p&gt;Hope it helps.&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=317" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Reporting/default.aspx">Reporting</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Data+Warehousing/default.aspx">Data Warehousing</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Design+Tips/default.aspx">Design Tips</category></item><item><title>Creating Slowly Changing Hierarchies in SSAS 2005</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2009/07/03/creating-slowly-changing-hierarchies-in-ssas-2005.aspx</link><pubDate>Fri, 03 Jul 2009 10:27:52 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:314</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=314</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2009/07/03/creating-slowly-changing-hierarchies-in-ssas-2005.aspx#comments</comments><description>&lt;p&gt;In a Data Warehouse, you’ll typically get at least one slowly changing hierarchy. You’ll probably also have other &lt;/p&gt;  &lt;p&gt;slowly changing attributes on the same dimension that are not in the hierarchy, causing many changes.&lt;/p&gt;  &lt;p&gt;Setting up this scenario in SSAS 2005 is easy, but it is also easy to do it wrong! Therefore I thought it would be&lt;/p&gt;  &lt;p&gt;useful to blog on how I do this and what potential pitfalls one can come across when attempting this for themselves.&lt;/p&gt;  &lt;p&gt;Consider a Product dimension that has a Supplier hierarchy. The business wants this hierarchy to change over&lt;/p&gt;  &lt;p&gt;time. Additionally there is another Type-2 attribute: RRP, which also changes over time.&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_3E925DEA.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_6E00CCB6.png" width="667" height="91" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So, Product ‘1234’ changed from SupplierGroup1-&amp;gt;SupplierA to SupplierGroup1-&amp;gt;SupplierB on ‘2002-Feb-01’. &lt;/p&gt;  &lt;p&gt;That supplier didn’t work out so it went back to SupplierGroup1-&amp;gt;SupplierA on ‘2002-Apr-01’. Also on’2002-Mar-01’ the price changed from £9.99 to £10.99.&lt;/p&gt;  &lt;p&gt;If browsing the cube by Supplier Hierarchy and Date you would want to see all sales for Jan-2002 and Apr-2002 &lt;/p&gt;  &lt;p&gt;onwards to by SupplierGroup1-&amp;gt;SupplierA and from Feb-2002 to end of Mar-2002 to SupplierGroup1-&amp;gt;SupplierB.&lt;/p&gt;  &lt;p&gt;So, lets see how you might go about setting this up in SSAS 2005.&lt;/p&gt;  &lt;p&gt;(For the purpose of this blog I have setup 3 dimensions all using the same Product dimension but setup &lt;/p&gt;  &lt;p&gt;differently and created a Fact Sales that has 1 sale for every day from 2002-Jan-01 to 2002-Apr-30).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Initially you might set this up like a normal type-1 hierarchy that does not track history, and expect SSAS to sort it out when things change. This is what I call the Bad Hierarchy Product dimension.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Bad Hierarchy Product Dimension&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_6796AC94.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_1DB824E4.png" width="476" height="386" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In this scenario we have created a Supplier hierarchy that goes Supplier Group-&amp;gt;Supplier-&amp;gt;Product Code. The product code being the natural key of the product dimension e.g. ‘1234’. &lt;/p&gt;  &lt;p&gt;You can see by the attribute relationship that Product Code rolls up into Supplier. Well, lets see what results that gives us.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_6E39904A.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_4C6DB7B9.png" width="572" height="151" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Hmm, not quite what we were hoping for. The hierarchy doesn’t seem to have changed at all!&lt;/p&gt;  &lt;p&gt;Well this is easy to explain. In the attribute relationship we have told SSAS that Product Code rolls up into Supplier. When SSAS processes dimensions it will retrieve the distinct value of every attribute and then aggregate them based on attribute relationships we define. SSAS will only have one value for product code ‘1234’ and that is, yep you guessed it, ‘1234’. SSAS will then find the first Supplier it finds for Product Code ‘1234’ and say, “right that’s it I’ve got what I want, no need to do anything else” hence the supplier hierarchy never changes. &lt;/p&gt;  &lt;p&gt;So the solution is simple:&lt;/p&gt;  &lt;p&gt;Type-1 attributes are attributes of the natural key (Product Code)&lt;/p&gt;  &lt;p&gt;Type-2 attributes are attributes of the surrogate key (Product Key)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So having just worked out this rule, you may try building the hierarchy by using the surrogate key as the bottom level of the hierarchy. I call this the duplicate product dimension&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Duplicate Product Dimension&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_69935FC3.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_5218AB92.png" width="515" height="381" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;This time, we have used the Product Key as the lowest level of the hierarchy, and all Type-2 attributes are attributes of the surrogate key. For the Product Key attribute we have changed the ‘Name’ property to be the Product Code, but the ‘Key’ property to be the surrogate key.&lt;/p&gt;  &lt;p&gt;So lets see what results that give us.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_7F1D7293.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_56325D8A.png" width="553" height="240" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Hmm well the good news is that the hierarchy has changed, but we seem to be getting duplicate product codes beneath each one. &lt;/p&gt;  &lt;p&gt;Well again this is easy to explain. We have 4 surrogate keys for product code ‘1234’. We have set the hierarchy to roll up from Product Key to Supplier. SSAS does not know that product key 1,2,3 and 4 have the same Product code and therefore you want to group by them so it just adds them all. &lt;/p&gt;  &lt;p&gt;So, at least our numbers above product code are correct, but this will still not do!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So let see how we do this properly.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Product Dimension&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;We create a new attribute in the dimension called ‘SupplierLeaf’ that has composite keys: Supplier Group, Supplier and Product Code and set the ‘Name’ property to ‘Product Code’.&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_3321EC1A.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_7062A0E1.png" width="489" height="351" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;We then setup the hierarchy as follows.&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_37F47A09.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_3C1E51CE.png" width="492" height="378" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So we use the new attribute ‘SupplierLeaf’ as the lowest level of the supplier hierarchy, but rename it to ‘Product Code’ within the hierarchy. We set supplier to be an attribute of Supplier leaf and set supplier leaf as an attribute of the surrogate key. So lets see how this looks.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/image_6C84B077.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="https://community.altiusconsulting.com/blogs/jakesmillie/image_thumb_51D8145E.png" width="499" height="173" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Bingo! we done it correctly. So, for every slowly changing hierarchy in a dimension you need to add a new ‘Leaf’ attribute. to get it to work correctly.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;One you have set this up, it is quite logical and easy to understand how to to it. But as I say, it is easy to get wrong. I hope this helps&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=314" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Data+Warehousing/default.aspx">Data Warehousing</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Kimball/default.aspx">Kimball</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SSAS/default.aspx">SSAS</category></item><item><title>Oracle Essbase 11 Excel Add-in Installation Gotcha</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2009/04/22/oracle-essbase-11-excel-add-in-installation-gotcha.aspx</link><pubDate>Wed, 22 Apr 2009 14:14:07 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:306</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=306</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2009/04/22/oracle-essbase-11-excel-add-in-installation-gotcha.aspx#comments</comments><description>&lt;p&gt;Today I installed the Oracle Essbase 11 Excel add-in. All worked well and I could connect to Essbase fine. &lt;/p&gt;  &lt;p&gt;When another user logged on to my machine and attempted to use it, the user could not connect to Essbase using the Excel add-in (nothing would seem to happen) and when trying to initialise the API would receive error #1030000.&lt;/p&gt;  &lt;p&gt;It seems that whilst installing the add-in, the normal environment variables ARBORPATH and ESSBASEPATH were created, but only as user defined variables.&lt;/p&gt;  &lt;p&gt;After installation you will need to check this and change them to system environment variables so that any user can use the add-in. They should both be set to:&lt;/p&gt;  &lt;p&gt;%HYPERION_HOME%\products\Essbase\EssbaseClient&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=306" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Hyperion/default.aspx">Hyperion</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Essbase/default.aspx">Essbase</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Essbase+API/default.aspx">Essbase API</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Oracle/default.aspx">Oracle</category></item><item><title>Kimball Microsoft Data Warehouse: What they don’t tell you! Part 4 – Dealing with Failed Lookups &amp; Early Arriving Facts – Alternative Approach</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/28/kimball-microsoft-data-warehouse-what-the-don-t-tell-you-part-4-dealing-with-failed-lookups-amp-early-arriving-facts-alternative-approach.aspx</link><pubDate>Tue, 28 Oct 2008 15:26:07 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:234</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=234</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/28/kimball-microsoft-data-warehouse-what-the-don-t-tell-you-part-4-dealing-with-failed-lookups-amp-early-arriving-facts-alternative-approach.aspx#comments</comments><description>&lt;p&gt;Welcome to my 4th and final post of my 4 part series of the Kimball Microsoft Data Warehouse toolkit. I hope you have found it interesting so far. If you have missed any posts, below is the outline of my series:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-1-scd-dates.aspx" target="_blank"&gt;Part 1 – SCD Dates - (What dates should I use in my RowStart and RowEnd dates?)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-2-type-1-changes-amp-historical-data.aspx" target="_blank"&gt;Part 2 – Type-1 Changes and Historical Data&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/27/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-3-a-composite-type-change-type-1-amp-type-2.aspx" target="_blank"&gt;Part 3 – A Composite Type Change (Type-1 &amp;amp; Type-2)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Part 4 – Dealing with Failed Lookups &amp;amp; Early Arriving Facts – Alternative Approach&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;h2&gt;Part 4 – Dealing with Failed Lookups &amp;amp; Early Arriving Facts – Alternative Approach&lt;/h2&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;The Problem&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Early arriving facts and implicitly failed dimension lookups are a common situation in Data Warehousing. One of the best examples of this would be the Customer Loyalty Card scheme. I am sure when shopping you have been asked to open up a new customer loyalty scheme, whilst being ensured that the current purchase will be added to your points total. &lt;/p&gt;  &lt;p&gt;Well, in this situation the point of sale will be the first time the new customer exists in a Data Warehouse. When we do a lookup against the Customer dimensions we won’t find the key. What do we do?&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;What Kimball Say&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Kimball give a few ideas in handling a situation like this, but their preferred method is using inferred dimension members. Which, in short, is adding a stub dimension member (for example in the problem described above just adding the Customer number – probably the loyalty card number – to the Customer Dimension and wait for the details of that customer to come into the dimension at a later date). You can read a bit more about this &lt;a href="http://www.rkimball.com/html/designtipsPDF/KimballDT57EarlyArriving.pdf" target="_blank"&gt;here&lt;/a&gt;. Additionally there is a more in depth explanation from Tom Stagg &lt;a href="http://community.altiusconsulting.com/blogs/tomstagg/archive/2008/05/18/data-warehousing-early-arriving-facts.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;This approach works very well for the problem described and is probably the best method for this type of problem. However, what happens if you need some dimensional data to work out fact data (e.g. If you have a situation where a new product can lend itself to early arriving facts – the transactional system is not kept up to date that well – you might want to store profit in the fact using the ETL to avoid calculating it. For this you need cost price of the product which will be dimensional data and not likely to feed from sales data, but wait a minute: This is a new product! We don’t know about it so how can we know the cost price).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;The Solution&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Well there are a few things you can do. &lt;/p&gt;  &lt;p&gt;- Don’t work out the profit of the sale (We don’t want to do this because this would make our Data Warehouse wrong)&lt;/p&gt;  &lt;p&gt;- Load it in initially with the profit as 0 and infer the new product. When we get the cost price of the new product we then update the fact. (This would work, but to me, it sounds very complex to add workflow into dimensions to then work out what facts, if any it needs to update and additionally updating fact rows is considered as best avoided)&lt;/p&gt;  &lt;p&gt;- Load them into a Fact_Failed_Lookup table. (This is my preferred approach and I will tell you why)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So, lets take a look at what I mean.&lt;/p&gt;  &lt;p&gt;Imagine we have a Product dimension with one product in and an Unknown member.&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Products_ID&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Product_Key&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Product_Name&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;RRP&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Cost_Price&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;RowIsCurrent&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;RowStartDate&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;RowEndDate&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;-1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0000&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Unknown&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.50&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;If we sell product 1234 we can work out the Profit using the cost price and the transaction price (Price - Cost Price).&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Transaction&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Date&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Product_Key&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Qty&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Price&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Profit&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;20081028&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.49&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;However if we sell a “Beer” (product code 5555) which isn’t in our Dimension we don’t yet know the cost price and cannot work out the profit.&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Transaction&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Date&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Product_Key&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Qty&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Price&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Profit&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;20081028&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;5555&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;4.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;xxx&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;So, we load the transactions as follows.&lt;/p&gt;  &lt;p&gt;Fact_Sales&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Transaction&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Date_ID&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Product_ID&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Qty&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Price&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Profit&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;20081028&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.49&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;Fact_Sales_Failed_Lookup&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Transaction&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Date_ID&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Date&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Product_ID&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Product_Key&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Qty&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Price&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Profit&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Estimate&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;20081028&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;20081028&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;-1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;5555&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;4.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;TRUE&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;When we load the cube we use a view that unions the Fact_Sales and the Fact_Sales_Failed_Lookup key values (additionally we add a view for RDBMS reporting access that does the same)&lt;/p&gt;  &lt;p&gt;This means the overall takings are correct but the profit may not be. I like to add Estimate to the cube so that business users can filter on estimates or not if they wish.&lt;/p&gt;  &lt;p&gt;Now, each day the failed lookup fact table is monitored by the Standing Data team where any invalid business / natural keys can be modified (e.g. Typo issues) and investigation into failures. Each day as part of the ETL the Failed Lookups are truncated and dimension lookups are re-tried (or this can be scheduled to do so on a weekend perhaps). If they fail again they go back into the failed lookups, if they succeed they go into the real fact.&lt;/p&gt;  &lt;p&gt;This is the workflow:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/FailedLookups_1B928B8B.jpg"&gt;&lt;img title="FailedLookups" style="display:inline;" height="676" alt="FailedLookups" src="https://community.altiusconsulting.com/blogs/jakesmillie/FailedLookups_thumb_14071C1E.jpg" width="489" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This approach has added advantages in that:&lt;/p&gt;  &lt;p&gt;- If typos occur in fact data they can be updated easily and the ETL just fixes it&lt;/p&gt;  &lt;p&gt;- If you want / need fact data more frequent than dimension processing, you can just add all fact data that is newer than your dimensional load date to your failed lookup table and mark them as estimates. The next time the dimensions are processed the estimate rows can simply flow into the real fact.&lt;/p&gt;  &lt;p&gt;However be warned using this approach making sure the Failed Lookup facts are actually looked at by the Standing Data Team and they don’t just keep growing and growing.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This concludes my series, which I hope you have found useful and valuable.&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=234" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Data+Warehousing/default.aspx">Data Warehousing</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Kimball/default.aspx">Kimball</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Kimball Microsoft Data Warehouse: What they don't tell you! Part 3 – A Composite Type Change (Type-1 &amp; Type-2)</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/27/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-3-a-composite-type-change-type-1-amp-type-2.aspx</link><pubDate>Mon, 27 Oct 2008 11:46:31 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:228</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=228</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/27/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-3-a-composite-type-change-type-1-amp-type-2.aspx#comments</comments><description>&lt;p&gt;This is the third part of my 4 part blog series that is aimed to give the world more insight on some of the Kimball Group concepts and, sometimes difference in opinions. Below is the outline of the series.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-1-scd-dates.aspx" target="_blank"&gt;Part 1&amp;#160; - SCD Dates - (What dates should I use in my RowStart and RowEnd dates?)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-2-type-1-changes-amp-historical-data.aspx" target="_blank"&gt;Part 2 – Type-1 Changes and Historical Data&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Part 3 – A Composite Type Change (Type-1 &amp;amp; Type-2)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/28/kimball-microsoft-data-warehouse-what-the-don-t-tell-you-part-4-dealing-with-failed-lookups-amp-early-arriving-facts-alternative-approach.aspx" target="_blank"&gt;Part 4 – Dealing with Failed Lookups &amp;amp; Early Arriving Facts – Alternative Approach&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Part 3 – A Composite Type Change (Type-1 &amp;amp; Type-2)&lt;/h2&gt;  &lt;p&gt;Today I am going to talk about a Type of change that is a combination of Type-1 and Type-2 changes. This is not the well understood &lt;a href="http://www.biblogs.com/2008/03/25/etl-subsystem-9-slowly-changing-dimensions-scd/" target="_blank"&gt;Type-1.5&lt;/a&gt; change but a composite Type change where multiple columns are related to one and other and each having a different change type. Below is the outline of the problem.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;u&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/u&gt;&lt;/h3&gt;  &lt;p&gt;In my previous posts I have used a simple Product dimension, and I will continue to use it. It is quite likely a Product dimension will have some sort of Product Category or Brand attributes e.g. Produce, Beers Wines &amp;amp; Spirits, etc. It is also quite likely that there will be a business key for the product categories e.g. 100 = Produce, 200 = Beers Wines &amp;amp; Spirits, etc. Lets take a look at what that might look like:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Products_ID&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Code&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RRP&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowIsCurrent&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowStartDate&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowEndDate&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In this simple dimension model it would be quite likely to have Department as a Type-2 and Department_Name as a Type-1. The business should be able to change the alias of the department without affecting their figures but if a product changes department then we don’t want historic sales to move with it.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So what would happen if we get a new row like this:&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Code&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RRP&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery &amp;amp; Frozen&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So, here the Product_Name (Type-1) has changed as has the Department_Name (Type-1). If we flow it through the Kimball sample ETL approach &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/SCD_Simple_3E82A535.jpg"&gt;&lt;img title="SCD_Simple" style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="649" alt="SCD_Simple" src="https://community.altiusconsulting.com/blogs/jakesmillie/SCD_Simple_thumb_69E6C62F.jpg" width="572" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In this situation the new row will flow down the Type-1 change route, updating the Product_Name and Department_Name for all historic rows and current row. The table will now look like this:&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Products_ID&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Code&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RRP&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowIsCurrent&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowStartDate&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowEndDate&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery &amp;amp; Frozen&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery &amp;amp; Frozen&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;This is all fine and expected. However have you spotted the issue yet? What happens if Product: 1234 changes Department e.g:&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Code&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RRP&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Produce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;In this situation the Checksum for Type-1 and Type-2 will mark a change; Department has changed from ‘2’-&amp;gt;’3’ causing a Type-2 checksum to change and Department_Name has also changed from ‘Grocery &amp;amp; Frozen’-&amp;gt;’Produce’ causing the Type-1 checksum to change. &lt;/p&gt;  &lt;p&gt;So, we update all the historic rows with the new Type-1 data and insert the new Type-2 row (after handling the Type-2 change). Using this logic the Dimension will now look like this.&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Products_ID&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Code&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RRP&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowIsCurrent&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowStartDate&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowEndDate&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;font color="#ff0000"&gt;Produce&lt;/font&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;font color="#ff0000"&gt;Produce&lt;/font&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;27-Oct-2008 00:00:00&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Produce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;27-Oct-2008 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&lt;strong&gt;Uh-oh!!&lt;/strong&gt; The current row is correct but the previous rows have had their Department_Name’s updated which is wrong!! We want the Dimension to look like this:&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Products_ID&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Code&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RRP&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowIsCurrent&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowStartDate&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowEndDate&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery &amp;amp; Frozen&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery &amp;amp; Frozen&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;27-Oct-2008 00:00:00&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Produce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;27-Oct-2008 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;&lt;u&gt;What Kimball Say&lt;/u&gt;&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;Well I haven’t read anywhere in Kimball media regarding this specific problem (however I would like to caveat that with the fact I haven’t read all their media), but they do give out a sample SSIS package that would fall over if a dimension was modelled in this way. I do not think by any stretch of the imagination that Kimball have provided this sample as an all conquering, all problem solving solution to all your dimension needs and why should they? However it would be quite easy to fall into the trap of assuming it would work for your dimension. This post’s purpose is to share knowledge and try and prevent people tripping over this problem.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;&lt;strong&gt;&lt;u&gt;The Solution&lt;/u&gt;&lt;/strong&gt;&lt;/h3&gt;  &lt;p&gt;Some of you may be reading this and thinking, “I would just use a Snowflake for the Department”, and yes this would solve the issue for the specific problem I have described (where you only have 1 level in the Department hierarchy), but this is probably quite unlikely in a production Data Warehouse, as you would probably have multiple levels; meaning you would just get the same problem in the Snowflaked dimension (I doubt you would want snowflake on top of snowflake for each level in the hierarchy).&lt;/p&gt;  &lt;p&gt;In actual truth I do not have a specific (generic) solution to this problem yet, except to say that you need to build in some logic into your Type-1 updates to ensure that if the related Type-2 attribute changes, you don’t update all the historic data also. Each problem will have a slightly different approach to best solving this problem. If I do work out a way to capture all issues I will be sure to post the solution. &lt;/p&gt;  &lt;p&gt;Let me know how you have solved this in the past.&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=228" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Data+Warehousing/default.aspx">Data Warehousing</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Kimball/default.aspx">Kimball</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Kimball Microsoft Data Warehouse: What they don't tell you! Part 2 – Type-1 Changes &amp; Historical Data</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-2-type-1-changes-amp-historical-data.aspx</link><pubDate>Fri, 24 Oct 2008 14:29:48 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:224</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=224</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-2-type-1-changes-amp-historical-data.aspx#comments</comments><description>&lt;p&gt;This is the second part of my 4 part blog that is aimed to give the world more insight on some of the Kimball Group concepts and, sometimes difference in opinions. In my first blog I talked about my difference in opinion to Kimball Group on handling Type-2 changes in dimensions and what dates to use to end and start the new row. You can read that &lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-1-scd-dates.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Below is an overview of my series:&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-1-scd-dates.aspx" target="_blank"&gt;Part 1 - SCD Dates - (What dates should I use in my RowStart and RowEnd dates?)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Part 2 – Type-1 Changes and Historical Data&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/27/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-3-a-composite-type-change-type-1-amp-type-2.aspx" target="_blank"&gt;Part 3 - A Composite Type Change (Type-1 &amp;amp; Type-2)&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/28/kimball-microsoft-data-warehouse-what-the-don-t-tell-you-part-4-dealing-with-failed-lookups-amp-early-arriving-facts-alternative-approach.aspx" target="_blank"&gt;Part 4 - Dealing with Failed Lookups &amp;amp; Early Arriving Facts - Alternative Approach&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;Part 2 – Type-1 Changes and Historical Data &lt;/h2&gt;  &lt;p&gt;In general the concepts of different Type changes within dimension processing is pretty well understood. There is a lot of material out there that describes the different types. &lt;a href="http://etl-tools.info/en/scd.html" target="_blank"&gt;ETL-Tools.info&lt;/a&gt; has a brief explanation if you need one. There is also a lot of information on how to deal with them within your ETL. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;The Problem&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In my experience many of your Dimensions within your Data Warehouse will have both Type-1 and Type-2 attributes. This is fine and also accepted, but when we have a member that has gone through many Type-2 changes over time, what do we do when we get a Type-1 change on that member?&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Consider the changes below:&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Products_ID&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Code&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RRP&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowIsCurrent&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowStartDate&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowEndDate&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;On 25th of October we get a Type-1 change to the Product name changing it to ‘Bag of Lettuce’&lt;/p&gt;  &lt;p&gt;Do we change Products_ID 1 and 2? or just 2 (the current row)?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;What Kimball Say&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In fairness, Kimball does suggest the correct way of dealing with this, but I would be more forceful and say it is THE way to deal with it. &lt;/p&gt;  &lt;p&gt;So Kimball suggests that we would normally change 1 &amp;amp; 2 (change for all historical rows also) and I believe this to be correct. So lets see why.&lt;/p&gt;  &lt;p&gt;If we had this data in the product dimension&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Products_ID&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Code&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Name&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RRP&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowIsCurrent&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowStartDate&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowEndDate&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;and this data in our sales fact &lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Date_ID&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Products_ID&lt;/strong&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Qty&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;20081023&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;20081024&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;How many “Bag of Lettuce” have we sold in total?&lt;/p&gt;  &lt;p&gt;Well lets see… This could be the SQL:&lt;/p&gt;  &lt;div&gt;   &lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;     &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;SELECT&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt;     Qty &lt;span style="color:#0000ff;"&gt;as&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;#39;Total Qty&amp;#39;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;FROM&lt;/span&gt; Fact_Sales s&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;INNER&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;JOIN&lt;/span&gt; Dim_Products p&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;ON&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;     s.Products_ID = p.Products_ID&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;WHERE&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;     p.Product_Name = &lt;span style="color:#006080;"&gt;&amp;#39;Bag of Lettuce&amp;#39;&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The answer given here would be 1. &lt;/p&gt;

&lt;p&gt;This is wrong because we have actually sold 2. (I appreciate that for this type of query I would probably use the Product_Key but I am just demonstrating the issue).&lt;/p&gt;

&lt;p&gt;This means our aggregations are invalid and not correct. If we change the historical row(s) (as suggested) as well, our aggregations remain in tact. &lt;/p&gt;

&lt;p&gt;So now our product dimension looks like this&lt;/p&gt;

&lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;
    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Products_ID&lt;/strong&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Product_Name&lt;/strong&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Code&lt;/strong&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;Dep_Name&lt;/strong&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RRP&lt;/strong&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowIsCurrent&lt;/strong&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowStartDate&lt;/strong&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;strong&gt;RowEndDate&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Bag of Lettuce&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Grocery&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;

&lt;p&gt;And if we use the same SQL above then we get the correct answer.&lt;/p&gt;

&lt;p&gt;It does mean on large dimensions that change quite frequently, Type-1 changes can become expensive within your ETL, but expensive is OK if you get the correct answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;The Solution&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The solution is easy. Always update all your history for Type-1 changes. &lt;/p&gt;

&lt;p&gt;An alternative to this approach is to create a view on top of your dimensions that joins on itself to retrieve the most recent Type-1 attributes but I see this as a bit of a hack and find it much more sensible to keep the dimension as clean and conformed as possible. &lt;/p&gt;

&lt;p&gt;Let me know your thoughts.&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=224" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Data+Warehousing/default.aspx">Data Warehousing</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Kimball/default.aspx">Kimball</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Kimball Microsoft Data Warehouse: What they don't tell you! Part 1 - SCD Dates</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-1-scd-dates.aspx</link><pubDate>Fri, 24 Oct 2008 10:36:00 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:223</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=223</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-1-scd-dates.aspx#comments</comments><description>&lt;p&gt;I was recently lucky enough to attend the Kimball University &amp;quot;Microsoft Data Warehouse in Depth&amp;quot; course, which I thoroughly recommend to anyone looking at the Microsoft toolkit for their Data Warehouse solution. It is well structured, well thought out and delivered in a clear and authoritative manner. Both Warren and Joy know their stuff (details about Warren and Joy can be found &lt;a href="http://www.kimballgroup.com/html/about.html" target="_blank"&gt;here&lt;/a&gt;). &lt;/p&gt;  &lt;p&gt;All this being said I did feel they missed out a few &amp;#39;gotchas&amp;#39;, and some of their methods and advice conflicted with a few of my personal opinions regarding Data Warehousing best practices (at least in the Microsoft Toolkit). This blog series is going to talk about these things and why I feel they are important.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Part 1 - SCD Dates&lt;/strong&gt; &lt;strong&gt;- (What dates should I use in my RowStart and RowEnd dates?)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/24/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-2-type-1-changes-amp-historical-data.aspx" target="_blank"&gt;Part 2 – Type-1 Changes and Historical Data&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/27/kimball-microsoft-data-warehouse-what-they-don-t-tell-you-part-3-a-composite-type-change-type-1-amp-type-2.aspx" target="_blank"&gt;Part 3 - A Composite Type Change (Type-1 &amp;amp; Type-2)&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/10/28/kimball-microsoft-data-warehouse-what-the-don-t-tell-you-part-4-dealing-with-failed-lookups-amp-early-arriving-facts-alternative-approach.aspx" target="_blank"&gt;Part 4 - Dealing with Failed Lookups &amp;amp; Early Arriving Facts - Alternative Approach&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;Part 1 - SCD Dates - (What dates should I use in my RowStart and RowEnd dates?)&lt;/h3&gt;  &lt;h4&gt;&lt;/h4&gt;  &lt;h4&gt;&lt;b&gt;&lt;u&gt;The Problem&lt;/u&gt;&lt;/b&gt;&lt;/h4&gt;  &lt;p&gt;When I Type-2 change a dimension member what Start and End dates do I use? &lt;/p&gt;  &lt;p&gt;Lets have a look at an example scenario:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Products_ID&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Product_Key&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Product_Name&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RRP&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RowIsCurrent&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RowStartDate&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RowEndDate&lt;/b&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now we load the dimensional data for 24-Oct-2008 which changes the RRP to £1.30 of Lettuce (we are all feeling the credit crunch squeeze!). This would be a Type-2 change. So how do we add a new row and what dates do we use in the RowStart and RowEnd dates? Is it 24-Oct-2008 or 23-Oct-2008?&lt;/p&gt;  &lt;h4&gt;&lt;/h4&gt;  &lt;h4&gt;&lt;/h4&gt;  &lt;p&gt;This is a problem that I have had arguments about in the past, and I bet if you ask 10 different Data Warehouse experts 5 will give you one answer and 5 will give you another. In the main I do not think it matters too much as long as you are consistent, &lt;b&gt;except &lt;/b&gt;when using Microsoft SQL Server as your RDBMS (at least pre 2008) or when you are loading more frequently than once per day.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;&lt;b&gt;&lt;u&gt;What Kimball Say&lt;/u&gt;&lt;/b&gt;&lt;/h4&gt;  &lt;p&gt;Kimball tell you to switch the row like below:&lt;/p&gt;  &lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;     &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Products_ID&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Product_Key&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Product_Name&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RRP&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RowIsCurrent&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RowStartDate&lt;/b&gt;&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RowEndDate&lt;/b&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;23-Oct-2008 00:00:00&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;        &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;     &lt;/tr&gt;   &lt;/table&gt;  &lt;p&gt;So the RowEnd date is the load date (remember we are loading 24-Oct-2008) –1 day. &lt;/p&gt;  &lt;p&gt;If we had a simple Sales fact when we do lookups loading our facts we can either do it like follows:&lt;/p&gt;  &lt;div&gt;   &lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;     &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   1:&lt;/span&gt; &lt;span&gt;SELECT&lt;/span&gt; &lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   2:&lt;/span&gt;      p.Products_ID &lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   3:&lt;/span&gt; &lt;span&gt;FROM&lt;/span&gt; conform.Fact_Sales f&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   4:&lt;/span&gt; &lt;span&gt;LEFT&lt;/span&gt; &lt;span&gt;OUTER&lt;/span&gt; &lt;span&gt;JOIN&lt;/span&gt; conform.Dim_Products p&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   5:&lt;/span&gt; &lt;span&gt;ON&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   6:&lt;/span&gt;     f.Product_Key = p.Product_Key&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   7:&lt;/span&gt; &lt;span&gt;AND&lt;/span&gt; f.&lt;span&gt;Date&lt;/span&gt; &amp;gt;= p.RowStartDate&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   8:&lt;/span&gt; &lt;span&gt;AND&lt;/span&gt; f.&lt;span&gt;Date&lt;/span&gt; &amp;lt;= p.RowEndDate&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;div&gt;
  &lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;
    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   1:&lt;/span&gt; &lt;span&gt;SELECT&lt;/span&gt; &lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   2:&lt;/span&gt;      p.Products_ID &lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   3:&lt;/span&gt; &lt;span&gt;FROM&lt;/span&gt; conform.Fact_Sales f&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   4:&lt;/span&gt; &lt;span&gt;LEFT&lt;/span&gt; &lt;span&gt;OUTER&lt;/span&gt; &lt;span&gt;JOIN&lt;/span&gt; conform.Dim_Products p&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   5:&lt;/span&gt; &lt;span&gt;ON&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   6:&lt;/span&gt;     f.Product_Key = p.Product_Key&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   7:&lt;/span&gt; &lt;span&gt;AND&lt;/span&gt; f.&lt;span&gt;Date&lt;/span&gt; &lt;span&gt;BETWEEN&lt;/span&gt; p.RowStartDate &lt;span&gt;AND&lt;/span&gt; p.RowEndDate&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;&lt;b&gt;&lt;u&gt;Why is it an Issue?&lt;/u&gt;&lt;/b&gt;&lt;/h4&gt;

&lt;p&gt;It is often common practice within a transactional system to mark dates something occurred as the current system Datetime (especially when using SQL Server i.e. GetDate())&lt;/p&gt;

&lt;p&gt;Pre SQL Server 2008 there is no Date type so all dates are time specific also. So if we consider a fact table feed like this:&lt;/p&gt;

&lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;
    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Transaction&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Date&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Product_Key&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Qty&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;23-Oct-2008 00:00:00&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;23-Oct-2008 09:00:00&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;3&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;

&lt;p&gt;Using the the Kimball approach the data we receive in the join will be:&lt;/p&gt;

&lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;
    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Transaction&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Products_ID&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;NULL&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;3&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;

&lt;p&gt;&lt;b&gt;Uh oh!!&lt;/b&gt; We are missing a product ID! This is because Transaction 2 happened at 9am (not exactly midnight) and due to the RowStart and RowEnd dates being accurate to the second (smalldatetime) or even 1000th of a second (datetime) we miss the join. To get round this you could strip the Fact date to just date (force it to be 00:00:00) but this can be expensive, especially when doing this for millions of fact rows &lt;b&gt;and&lt;/b&gt; when there is an alternative way.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;&lt;b&gt;&lt;u&gt;The Solution&lt;/u&gt;&lt;/b&gt;&lt;/h4&gt;

&lt;p&gt;Instead of using the load day –1 we use the load day as the RowEndDate so our Lettuce now looks like this:&lt;/p&gt;

&lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;
    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Products_ID&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Product_Key&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Product_Name&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RRP&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RowIsCurrent&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RowStartDate&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;RowEndDate&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0.99&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;0&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;01-Jan-1900 00:00:00&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1234&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;Lettuce&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1.3&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;24-Oct-2008 00:00:00&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;31-Dec-9999 00:00:00&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;

&lt;p&gt;We now change our join very slightly to the below: &lt;/p&gt;

&lt;div&gt;
  &lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;
    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   1:&lt;/span&gt; &lt;span&gt;SELECT&lt;/span&gt; &lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   2:&lt;/span&gt;      p.Products_ID &lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   3:&lt;/span&gt; &lt;span&gt;FROM&lt;/span&gt; conform.Fact_Sales f&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   4:&lt;/span&gt; &lt;span&gt;LEFT&lt;/span&gt; &lt;span&gt;OUTER&lt;/span&gt; &lt;span&gt;JOIN&lt;/span&gt; conform.Dim_Products p&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   5:&lt;/span&gt; &lt;span&gt;ON&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   6:&lt;/span&gt;     f.Product_Key = p.Product_Key&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span&gt;   7:&lt;/span&gt; &lt;span&gt;AND&lt;/span&gt; f.&lt;span&gt;Date&lt;/span&gt; &amp;gt;= p.RowStartDate&lt;/pre&gt;

    &lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;border-right-style:none;border-left-style:none;border-bottom-style:none;"&gt;&lt;span&gt;   8:&lt;/span&gt; &lt;span&gt;AND&lt;/span&gt; f.&lt;span&gt;Date&lt;/span&gt; &lt;span&gt;&amp;lt;&lt;/span&gt;  p.RowEndDate&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;So we only join on rows less than but not equal to the RowEndDate. So now we get these values:&lt;/p&gt;

&lt;table style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;" cellspacing="1" cellpadding="1"&gt;
    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Transaction&lt;/b&gt;&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;&lt;b&gt;Products_ID&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;1&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;3&lt;/td&gt;

      &lt;td style="border-right:black 1px solid;border-top:black 1px solid;border-left:black 1px solid;border-bottom:black 1px solid;"&gt;2&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;

&lt;p&gt;&lt;b&gt;Yay!!&lt;/b&gt; we are not missing any Product_IDs now, and all is happy. &lt;/p&gt;

&lt;p&gt;This approach has saved expensive date conversions when they are not necessary. As long as the RowEndDate of the previous row is the same as the RowStartDate of the next row then all is happy. This is my standard approach and it is also an approach that will work if you need to move to real time processing (changes occur multiple times a day). &lt;/p&gt;

&lt;p&gt;I hope you can see how this approach ticks more of the boxes in issue resolution. Let me know about your thoughts and how you have tackled this problem in the past.&lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=223" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Data+Warehousing/default.aspx">Data Warehousing</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Kimball/default.aspx">Kimball</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SQL+Server/default.aspx">SQL Server</category></item><item><title>Essbase API Load Data - Error 1042015 - Network error: Cannot Locate Connect Information For [%s]</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/08/15/essbase-api-load-data-error-1042015-network-error-cannot-locate-connect-information-for-s.aspx</link><pubDate>Fri, 15 Aug 2008 10:06:41 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:195</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=195</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/08/15/essbase-api-load-data-error-1042015-network-error-cannot-locate-connect-information-for-s.aspx#comments</comments><description>&lt;p&gt;Today I was trying to load data into Essbase v7.1.5 using the VB API command EsbImport.&lt;/p&gt; &lt;p&gt;The Essbase API documentation is great and gives you very useful code examples. The example they give for EsbImport is defined below:&lt;/p&gt; &lt;div&gt; &lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span style="color:#0000ff;"&gt;Declare&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Function&lt;/span&gt; EsbImport &lt;span style="color:#0000ff;"&gt;Lib&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;ESBAPIN&amp;quot;&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;ByVal&lt;/span&gt; hCtx &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Long&lt;/span&gt;, Rules &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; ESB_OBJDEF_T, &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;                                          Data &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; ESB_OBJDEF_T, User &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; ESB_MBRUSER_T, &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;                                          &lt;span style="color:#0000ff;"&gt;ByVal&lt;/span&gt; ErrName &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;String&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;ByVal&lt;/span&gt; AbortOnError &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Integer&lt;/span&gt;) &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;                                          &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Long&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt; ESB_Import ()&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; sts          &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Long&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   &lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; Rules        &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; ESB_OBJDEF_T&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; Data         &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; ESB_OBJDEF_T&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   &lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; User         &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; ESB_MBRUSER_T&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; ErrorName    &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;String&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   &lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; AbortOnError &lt;span style="color:#0000ff;"&gt;As&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Integer&lt;/span&gt;    &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;*********************************&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39; Rules file resides at the server&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;********************************* &lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   Rules.hCtx     = hCtx&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   Rules.Type     = ESB_OBJTYPE_RULES    &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   Rules.AppName  = &lt;span style="color:#006080;"&gt;&amp;quot;Demo&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   Rules.DbName   = &lt;span style="color:#006080;"&gt;&amp;quot;Basic&amp;quot;&lt;/span&gt;   &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   Rules.FileName = &lt;span style="color:#006080;"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;           &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;********************************&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39; Data file resides at the server&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;******************************** &lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   Data.hCtx      = hCtx&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   Data.Type      = ESB_OBJTYPE_TEXT      &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   Data.AppName   = &lt;span style="color:#006080;"&gt;&amp;quot;Demo&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   Data.DbName    = &lt;span style="color:#006080;"&gt;&amp;quot;Basic&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   Data.FileName  = &lt;span style="color:#006080;"&gt;&amp;quot;Data&amp;quot;&lt;/span&gt;               &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;********************************&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39; Specify file to redirect errors &lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39; to if any &lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;******************************** &lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   ErrorName      = &lt;span style="color:#006080;"&gt;&amp;quot;IMPORT.ERR&amp;quot;&lt;/span&gt;   &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;*************************&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39; Abort on the first error &lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;*************************&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   AbortOnError   = ESB_YES   &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;*******&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39; Import&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;   &lt;span style="color:#008000;"&gt;&amp;#39;*******&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;   sts            = EsbImport (hCtx, Rules, Data, User, ErrorName, AbortOnError)    &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt; &lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This code however is incomplete and will generate an Essbase error 1042015 - Network error: Cannot Locate Connect Information For [%s]. &lt;/p&gt;
&lt;p&gt;The problem is that the database you have selected to import data into is not active. Therefore before the EsbImport command is called, you need to call EsbSetActive, like below&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;&lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; pAccess &lt;span style="color:#0000ff;"&gt;AS&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Integer&lt;/span&gt;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:white;border-bottom-style:none;"&gt;sts = EsbSetActive (hCtx, &lt;span style="color:#006080;"&gt;&amp;quot;Demo&amp;quot;&lt;/span&gt;, &lt;span style="color:#006080;"&gt;&amp;quot;Basic&amp;quot;&lt;/span&gt;, pAccess)&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This will fix your error 1042015 woes. &lt;/p&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=195" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Hyperion/default.aspx">Hyperion</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Essbase/default.aspx">Essbase</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Essbase+API/default.aspx">Essbase API</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Oracle/default.aspx">Oracle</category></item><item><title>Data Warehousing - ETL Dealing With Large Dimensions in SSIS</title><link>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/06/20/data-warehousing-etl-dealing-with-large-dimensions-in-ssis.aspx</link><pubDate>Fri, 20 Jun 2008 16:08:00 GMT</pubDate><guid isPermaLink="false">2e5ec144-c93e-4221-9fd2-7c9cff35ec80:163</guid><dc:creator>JakeSmillie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.altiusconsulting.com/blogs/jakesmillie/rsscomments.aspx?PostID=163</wfw:commentRss><comments>http://community.altiusconsulting.com/blogs/jakesmillie/archive/2008/06/20/data-warehousing-etl-dealing-with-large-dimensions-in-ssis.aspx#comments</comments><description>&lt;h3&gt;&lt;/h3&gt;
&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;This is the first part of a 2 part blog that outlines techniques in dealing with very large dimensions (or small ones for that matter) when going through your ETL (Extract, Transform &amp;amp; Load) process in your data warehouse using Microsoft SSIS (SQL Server Integration Services) as your ETL tool.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;The Problem&lt;/h3&gt;
&lt;p&gt;- You have designed your data warehouse and you are left with a very large and complex dimension. (When I say large and complex I mean a million plus rows and 10 plus data sources, but the process works on any size of dimension)&lt;/p&gt;
&lt;p&gt;- You still need to meet your ETL time requirements and it would not be plausible to process the full dimension for each ETL run. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For the purpose of this blog I have simplified the problem to a small simple dimension.&lt;/p&gt;
&lt;p&gt;Here is a Entity Relationship diagram of the source for our dimension.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/WindowsLiveWriter/DataWarehousingETLDealingWithLargeDimens_CA95/DataWarehouse_Diagram_1_2.jpg"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="99" alt="DataWarehouse_Diagram_1" src="https://community.altiusconsulting.com/blogs/jakesmillie/WindowsLiveWriter/DataWarehousingETLDealingWithLargeDimens_CA95/DataWarehouse_Diagram_1_thumb.jpg" width="558" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is a very simplified Product dimension and the end result we want is:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/WindowsLiveWriter/DataWarehousingETLDealingWithLargeDimens_CA95/DataWarehouse_Diagram_2_2.jpg"&gt;&lt;img style="BORDER-RIGHT:0px;BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:0px;" height="218" alt="DataWarehouse_Diagram_2" src="https://community.altiusconsulting.com/blogs/jakesmillie/WindowsLiveWriter/DataWarehousingETLDealingWithLargeDimens_CA95/DataWarehouse_Diagram_2_thumb.jpg" width="165" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;Solution&lt;/h3&gt;
&lt;p&gt;To start I would like to caveat this with the fact that this is by no means the only and definitive way but a way that has worked for me and works well.&lt;/p&gt;
&lt;p&gt;All ETL processed go through 4 main steps:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Extract&lt;/strong&gt;&amp;nbsp;&amp;nbsp; - Extract the data from source systems&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Clean&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Clean the data for your data warehouse. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Conform&lt;/strong&gt; - Change the data into your data warehouse format&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Load&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Load it into your data warehouse&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Extract&lt;/h4&gt;
&lt;p&gt;Firstly we need to Extract the 3 source tables (Product, Product_Pricing, Product_Hierarchy). We only want to extract changes to these tables since the last load as we do not want to process the whole dimension each time. There are many ways that this can be done and is not part of the scope of this blog.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;Clean&lt;/h4&gt;
&lt;p&gt;In clean we keep a current snapshot of the source table and mark any rows that change to &amp;#39;changed&amp;#39;. For example if a department (1, Produce) in Product_Hierarchy changes to (1, Food &amp;amp; Produce) we change that row and mark it as changed. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here is the sample data I am using in the clean area.&lt;/p&gt;
&lt;p&gt;Product_Hierarchy&lt;/p&gt;
&lt;table class="" cellspacing="0" cellpadding="2"&gt;

&lt;tr&gt;
&lt;td class=""&gt;&lt;strong&gt;Department&lt;/strong&gt;&lt;/td&gt;
&lt;td class=""&gt;&lt;strong&gt;Department_Name&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;1&lt;/td&gt;
&lt;td class=""&gt;Produce&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;2&lt;/td&gt;
&lt;td class=""&gt;Grocery&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;3&lt;/td&gt;
&lt;td class=""&gt;BWS&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;4&lt;/td&gt;
&lt;td class=""&gt;Technology&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;Products&lt;/p&gt;
&lt;table class="" cellspacing="0" cellpadding="2"&gt;

&lt;tr&gt;
&lt;td class=""&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;
&lt;td class=""&gt;&lt;strong&gt;Product_Name&lt;/strong&gt;&lt;/td&gt;
&lt;td class=""&gt;&lt;strong&gt;Department&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;1234&lt;/td&gt;
&lt;td class=""&gt;Lettuce&lt;/td&gt;
&lt;td class=""&gt;2&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;1235&lt;/td&gt;
&lt;td class=""&gt;Potato&lt;/td&gt;
&lt;td class=""&gt;2&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;1236&lt;/td&gt;
&lt;td class=""&gt;Tomato&lt;/td&gt;
&lt;td class=""&gt;2&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;2341&lt;/td&gt;
&lt;td class=""&gt;Crisps&lt;/td&gt;
&lt;td class=""&gt;1&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;2342&lt;/td&gt;
&lt;td class=""&gt;Biscuits&lt;/td&gt;
&lt;td class=""&gt;1&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;3241&lt;/td&gt;
&lt;td class=""&gt;DVD&lt;/td&gt;
&lt;td class=""&gt;4&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;3242&lt;/td&gt;
&lt;td class=""&gt;CD&lt;/td&gt;
&lt;td class=""&gt;4&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;4321&lt;/td&gt;
&lt;td class=""&gt;Fosters&lt;/td&gt;
&lt;td class=""&gt;3&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;4322&lt;/td&gt;
&lt;td class=""&gt;Stella&lt;/td&gt;
&lt;td class=""&gt;3&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;4323&lt;/td&gt;
&lt;td class=""&gt;Pinot Grigio&lt;/td&gt;
&lt;td class=""&gt;3&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;Product_Pricing&lt;/p&gt;
&lt;table class="" cellspacing="0" cellpadding="2"&gt;

&lt;tr&gt;
&lt;td class=""&gt;&lt;strong&gt;Product_Key&lt;/strong&gt;&lt;/td&gt;
&lt;td class=""&gt;&lt;strong&gt;RRP&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;1234&lt;/td&gt;
&lt;td class=""&gt;0.99&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;1235&lt;/td&gt;
&lt;td class=""&gt;0.89&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;1236&lt;/td&gt;
&lt;td class=""&gt;2.99&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;2341&lt;/td&gt;
&lt;td class=""&gt;1.89&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;2342&lt;/td&gt;
&lt;td class=""&gt;1.47&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;3241&lt;/td&gt;
&lt;td class=""&gt;3.57&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;3242&lt;/td&gt;
&lt;td class=""&gt;2.54&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;4321&lt;/td&gt;
&lt;td class=""&gt;1.50&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;4322&lt;/td&gt;
&lt;td class=""&gt;4.20&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=""&gt;4323&lt;/td&gt;
&lt;td class=""&gt;2.30&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So this is the data we have in our clean tables. We now need to merge these tables into one that would be used as out source dimension to conform.&lt;/p&gt;
&lt;p&gt;This is the SQL used:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:white;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#0000ff;"&gt;SELECT&lt;/span&gt; &lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;       p.[Product_Key]        &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; [Source_Product_Key]&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:white;BORDER-BOTTOM-STYLE:none;"&gt;      ,p.[Product_Name]        &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; [Source_Product_Name]&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;      ,p.[Department]        &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; [Source_Department]&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:white;BORDER-BOTTOM-STYLE:none;"&gt;      ,h.[Department_Name]    &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; [Source_Department_Name]&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;      ,price.[RRP]            &lt;span style="COLOR:#0000ff;"&gt;as&lt;/span&gt; [Source_RRP]&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:white;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#0000ff;"&gt;FROM&lt;/span&gt; [clean].[Products] p &lt;span style="COLOR:#008000;"&gt;-- this is the driving table &lt;/span&gt;&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#0000ff;"&gt;LEFT&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;OUTER&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;JOIN&lt;/span&gt; [clean].[Product_Pricing] price&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:white;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#0000ff;"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;    p.[Product_Key] = price.[Product_Key]&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:white;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#0000ff;"&gt;LEFT&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;OUTER&lt;/span&gt; &lt;span style="COLOR:#0000ff;"&gt;JOIN&lt;/span&gt; [Clean].[Product_Hierarchy] h&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#0000ff;"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:white;BORDER-BOTTOM-STYLE:none;"&gt;    p.[Department] = h.[Department]&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#0000ff;"&gt;WHERE&lt;/span&gt;&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:white;BORDER-BOTTOM-STYLE:none;"&gt;    p.[Changed] = 1 &lt;span style="COLOR:#008000;"&gt;-- driving table has changed&lt;/span&gt;&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:#f4f4f4;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#0000ff;"&gt;OR&lt;/span&gt;    price.[Changed] = 1 &lt;span style="COLOR:#008000;"&gt;-- the price  has changed &lt;/span&gt;&lt;/pre&gt;&lt;pre style="PADDING-RIGHT:0px;PADDING-LEFT:0px;FONT-SIZE:8pt;PADDING-BOTTOM:0px;MARGIN:0em;OVERFLOW:visible;WIDTH:100%;COLOR:black;BORDER-TOP-STYLE:none;LINE-HEIGHT:12pt;PADDING-TOP:0px;FONT-FAMILY:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BACKGROUND-COLOR:white;BORDER-BOTTOM-STYLE:none;"&gt;&lt;span style="COLOR:#0000ff;"&gt;OR&lt;/span&gt;    h.[Changed] = 1 -- the department has changed &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This merges the the tables and makes sure we get all changes (by using the OR Changed flags). One of the problems you get with multiple sources is that if the Department_Name in Product_Hierarchy changes it could change more than one row in the Dimension (so you can&amp;#39;t just use your driving product table to track changes).&lt;/p&gt;
&lt;p&gt;For example, if (1, Produce) changes to (1, Food &amp;amp; Produce) as previously mentioned we need to make sure Products 2341 and 2342 are included to conform. Holding the full snapshot of your relational data in your staging area allows you to get ALL changes and only load changes (not the whole dimension). This approach can save many minutes on large dimensions.&lt;/p&gt;
&lt;p&gt;The above solution does require the storage space in your staging database but this is a small price to pay for time saved.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Part 2 of this blog will explain how to flow this through a conform stage in SSIS. You can download the sample database I have used to have a play for yourself below&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:21640030-2250-443f-a7a4-4df32fa88aec" style="PADDING-RIGHT:0px;DISPLAY:inline;PADDING-LEFT:0px;PADDING-BOTTOM:0px;MARGIN:0px;PADDING-TOP:0px;"&gt;
&lt;div&gt;&lt;a href="https://community.altiusconsulting.com/blogs/jakesmillie/WindowsLiveWriter/DataWarehousingETLDealingWithLargeDimens_CA95/DataWarehouse_Play.zip" target="_self"&gt;DataWarehouse_Play.zip&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://community.altiusconsulting.com/aggbug.aspx?PostID=163" width="1" height="1"&gt;</description><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/ETL/default.aspx">ETL</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/Data+Warehousing/default.aspx">Data Warehousing</category><category domain="http://community.altiusconsulting.com/blogs/jakesmillie/archive/tags/SSIS/default.aspx">SSIS</category></item></channel></rss>