.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

SCD Type II with Date Dimension

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :Sql Server

We have emp_elig table as mentioned below

SurKey	GroupID		ID		ID_Seq		datebegin				dateend			elig_status	

19833	100000-01		100-01		000		2006-01-01 00:00:00		2010-12-30 00:00:00		1	

19835	100000-01		100-01		000		2010-12-31 00:00:00		2025-01-01 00:00:00		0	

19837	100000-01		100-01		001		2006-01-01 00:00:00		2006-12-31 00:00:00		1	

19838	100000-01		100-01		001		2007-01-01 00:00:00		2025-01-01 00:00:00		0	

19841	100000-01		100-01		002		2006-01-01 00:00:00		2009-02-16 00:00:00		1	

19843	100000-01		100-01		002		2009-02-17 00:00:00		2025-01-01 00:00:00		0

Note: elig_status 1 = Eligible

I do have SCD in SSAS which shows the hierarchy as mentioned above. Now I want to see something like given below:

                            Q1     Q2     Q3     Q4

Emp_Elig_Count       1        2       1       1


I don't know how can I link my DimTime (Date) between DateBegin and DateEnd of the above tabl

View Complete Post

More Related Resource Links

Conversion from string to type 'Date' is not valid



Im receiving a strange error Error Message: Conversion from string "15/08/2010 22:21:35" to type 'Date' is not valid.

I know this is generally down to cultural date formats etc, however the reason this is strange is it just randomly occured twice in the last week, the website has been running since october and nothing has changed,

The error constantly occured until the IIS was reset and recompilled the site, its been running fine since, however im just trying to figure out what could cause such an error to occur.

I've narrowed it down to a line of code which is:

bktime = DReader.Item("Bktime").ToString

bktime = Year(CDate(bktime)) & "-" & fmt(Month(CDate(bktime)), 2) & "-" & fmt(Day(CDate(bktime)), 2)

Has anyone else encountered this randomly occuring and is there anything i can put in place to prevent this in future?



Parent-Child relationship on a Type 2 (SCD) Dimension

For a Type 2 slowly changing dimension (SCD) such as Employee with a Parent-Child relationship, how do you handle the explosion of new rows when a high ranking employee has an attribute change?   It will require terminating the high ranking employee row and adding a new current row with a new surrogate key. Then every employee row below this employee will also have to be terminated and a new current row added with the new surrogate key of the parent.   This will have to be performed 1 level at a time so the subordinate rows will have the new surrogate key of their immediate parent.   For a large organization such as 20,000 employees, this will result in a dimension with hundreds of thousands rows in a relatively short time.   Is there a better way to model this?

Problem with Dimension of type Account

Hi, I have a simple fact table where I have a dimension time and a dimension of type acount. The fact table looks like this FinanceKey AccountKey ProfitCenterKey DateKey DateAlternateKey ScenarioKey Amount 1 11 5 7308 2010-01-01 1 131 2 11 3 7308 2010-01-01 1 62115 3 11 0 7308 2010-01-01 1 27626 4 11 6 7308 2010-01-01 1 12 5 11 2 7308 2010-01-01 1 74316 6 11 7 7308 2010-01-01 1 14 7 11 5 7339 2010-02-01 1 147 The account dimension looks like this AccountKey AccountAlternateKey ParentAccountKey AccountName_en AccountName_de AccountType Operator CustomMembers ValueType CustomMemberOptions 1 1 NULL Statistical Accounts Statistische Kennzahlen Statistical ~ NULL Units NULL 11 11 1 Customer Count Anz. Kunden Balances ~ NULL Units NULL If I browse my cube I get no data for the measure amount. When I remove hte parent Account "Statistical Accounts" and ste the parent of "Customer Count" to NULL I will get the correct Customer count. Any idea?

Getting counts by 2nd Date Dimension Attribute with Snapshot Style Fact Table

  I have an MDX question finding hard to solve.  I have a Snapshot Fact Table with a snapshot of the records in the source system for each batch date.  All records in the fact table are assigned the batch date with the batch date key.  There are many records for each day and each batch date is an entire copy of the source records.  So, the grain of the fact table is one record for each batch date that exists in the source system.  These facts rows have another date in them for when the record was entered.  This date is different from the batch date in that the batch date is based on the day the batch was processed and the entered date is based on when the record was entered.  If a record was entered many days before, its batch date will be today but its entered date will be several days ago.  Therefore each day a copy of all the records entered the previous batch date and all the records added on today's batch date are present. Fact Table : FactSnaphshotKey (surrogate for easier administration) BatchDateKey (link to batch date dimension – date dimension, first in dimension list so it is used for semi aggregate measures) EnteredDateKey (link to entered date dimension – date dimension) Facts Count – measure for fact table - default measure from Analysis Services cube 2 Dim

In SSIS 2005 how can I implement Slowly Changing Dimension Type 6

Hi I can't see SCD Type 6 in SSIS 2005 ,how do I get add  into my data flow task and if anybody can explain me step by step process for SCD type 6

Running sum calculation based off date dimension?

I have a fairly simple calculated measure which does a running sum of a particular measure : --This does a running sum of the Net Measure up until the previous date (basically a "Starting Count" for a period. Sum(PeriodsToDate([Change Date].[Year - Month - Date].Levels(0), [Change Date].[Year - Month - Date].PrevMember), [Measures].[Net]) The problem is I have added a second hierarchy in the date dimension that includes quarter called [Year - Quarter - Month - Date]. Is there anyway around not having to create a seperate running sum calculated measure to use this new hierarchy? The PrevMember in the initial calculated measure works, although it reports the wrong number when used in conjunction with the Quarter hierarchy because it gets the PrevMember in the other hierarchy. What is the best practice for this situation?Craig

Problem with date type

hi i receive this date: `9/20/2010 3:32:32 PM` i need to convert to datetime. i try:     DateTime DateFrom = DateTime.ParseExact("9/20/2010 3:32:32 PM", "dd/M/yyyy", CultureInfo.InvariantCulture);                     but i get error: `String was not recognized as a valid DateTime.` in my computer the region is: `Hebrew (Israel)  dd/MM/yyyy for short date and hh:mm for short time` how to fix it ? thank's in advance

How to insert SQL2008 date data type using ADODB.Recordset and Native Client?



I am working with a classic ASP application that we are trying to keep hobbling along while it gets rewritten.  The underlying database has been upgraded many times and is currently running on SQL Server 2008.

Recently a column of table was updated from a smalldatetime (with a check constraint to ensure it didn't have any time values) to simply the date type, but the code now does not work.  I was originally using SQLOLEDB, and was confident that treating the date as a string would be find with our client.  Unfortunately it does not, nor does it work using the SQLNCLI10 client.

This is the stripped down code:

Set adoConnection = aspServer.CreateObject("ADODB.Connection")
adoConnection.Open "Provider=SQLNCLI10"  ' Details Removed
Set adoRS = aspServer.CreateObject("ADODB.Recordset")
adoRS.CursorLocation = adUseClient
adoRS.Open "SELECT * FROM TestTable WHERE id = 0", adoConnection, adOpenKeyset, adLockOptimistic, adCmdText
adoRS("datecolumn") = "09/20/2010"

On the update line, I get the following error:

Microsoft SQL Server Native Client 10.0 error '80040e07'
Error convertin

How to limit a Many to Many Dimension by a secondary Date dimension


Hello MDX gurus,


I have tried posting my problem before, however, I still haven’t gotten a response. Therefore I am going to try again... I am new to MDX, I have had a bit of experience, but nothing more complicating than creating simple calculated measures.


I have a data source which contains Injuries and their Status. An Injury can have it’s Status change depending on whether a doctor visit is involved. For example, an Injury can start out as a First Aid (FA) then change to a Medical Aid (MA) if the person seeks medical attention later on. It can then change to a Lost Time (LT) incident if told to take time off from their doctor. Then, if WCB declines their claim, the Injury can change back to a Medical Aid (MA). The LT/FA/MA status is called the Recordability by our business users.


Therefore, one Injury can have multiple Recordability records, and the ERD looks like this:


Injury -> InjuryStatus <- RecordableInjury


When a report is run, the Status (or RecordableInjury) that appears needs to be the latest one in the selected reporting period (based on StatusDate) for each Injury. Therefore, each Injury may be counted only once within a time period (i.e. Year, Quarter, Month, Week), with the most recent Status appearing for that time period.


Isolate only the Date part from MDX returned dimension



I have an MDX query which returns a date dimension values as below

02 Aug 2010
03 Aug 2010
04 Aug 2010

Is there a MDX function i can apply only to isolate only the date part of the values like 02 Aug, 03 Aug.

I can do this quite eaily in SQL using Datepart..but i wasn't able to find a similar function for mdx.

Thank you for your assistance.





MDX Calculations error - The 'Date Calculations' dimension contains more than one hierarchy, there


Hi all,

I am using http://www.obs3.com/pdf/A%20Different%20Approach%20to%20Time%20Calculations%20in%20SSAS.pdf to make a seperate dimension for the data calculations, which works in my Sales cube. But when I use the same dimension in an other cube (Called 'Procurement') and copy the MDX in the calculations tab, I am getting some errors:

Error    57    MdxScript(Procurement) (9, 8) The 'Date Calculations' dimension contains more than one hierarchy, therefore the hierarchy must be explicitly specified.        0    0   

But the 'Date Calculations' dimension does not have a hierarchy!

Now I don't know why I am getting these errors, could you guys help me out so I can understand them and fix the problem?

Thanks you in advance,


Conversion from string "09/28/10 9.00AM" to type 'Date' is not valid.


I am getting the below error. Please see my code below and let me know what is wrong.


dim sDatetime as string = startdate & " " &starttime & "AM"

dim dt as Date = CDate(sDatetime)

I am getting the Conversion from string "09/28/10 9.00AM" to type 'Date' is not valid error in this line. 

MDX Date Dimension Help


rewriting my original question...

when i don't include the [Dim Date].[Month Number Of Year]  on the columns, i get the correct value for Amount which is the amount between the date range in my where clause by days.

when i include it, it returns all of the amounts belonging to the [Month Number Of Year] which may be outside the date range.

how do i write this statement so that i can return the month, but only with the amounts entered within the number of days?

do i need to convert the [Dim Date].[Day] value?  if so, how?


-- incorrect results

non empty

on columns,

non empty
   [Dim Date].[Month Number Of Year].members

on rows
from myCube
         [Dim Date].[2007/01/01]:[Dim Date].[2007/01/15]

-- correct results, but displays the days, i want it aggregated by month.

   non empty

Data type mismatch in criteria expression: date



I am getting a "Data type mismatch in criteria expression" error when trying the following SELECT statement.

strdt and spdate are Date types in my vb codebehind and the Contract field name is a DateTime field.

thanks for your help



nmxSQL As String = "SELECT * FROM Nymex WHERE (NymexID='" & nymID & "' And Contract>='" & strdt & "' And Contract<='" & spdate & "')"

Unalbe to create date dimension with fiscal start date 29 Sept

I am trying to create date dimension with 29-Sept as starting date of fiscal year. But the dimension wizard always displays errors related date conversion. The following is the environment I tried.

OS : Windows XP

SQL Server R2

Please help.


Thanks in advance.


Hamlin Stephen

Multiple companies and fiscal calendars in date dimension table

We are creating an application where different companies can have their own fiscal calendar starting on different dates. For example one company’s fiscal year may start in April and some others in Sep. Also fiscal calendars may start at any date. (E.g. 29 Sept).

These fiscal calendars would be created for parent companies. We have added the parent company ids to the date dimension table. Please suggest the correct way of setting the attribute relationship in the above scenario. If this is not the right method to do this, please suggest the correct design approach for achieving this.


Thanks in advance,


Hamlin Stephen

Check if Type is numeric, text or date



How can i check if a type (of class Type) is numeric, text or date? Is there a simple method for this already?
Currently I'm checking it like this:

if(type == typeof(Int16) || type == typeof(UInt16) || type == typeof(Int32) ... and so on) return "numeric";

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend