Why data is repeating in ssas dimension - ssas

I have an SSAS cube with time as one of the dimention.It contains hierarchy like year-quarter-month etc.When i drag and drop the this on SQL Server Managment Studio window(brows), it looks like data is repeating.For example,year is like 2002,2002,2003,2003,.. etc.If i expand first 2002 i can see 1st quarter under that.If i expand second 2002 i can see 2nd quarter etc..Can any one tell what is the reason? how can i change to single data?

First of all are you using your own Date Dimension table. If so, make sure you use the correct key for Date, Month, Quarter and Year. For example, normally the date dimension has YearMonth column used as the key for the Month attribute (eg 2012-04). If you don't have such a column you will need to pick a composite key for Month (Year and Month). Also, a good way to check is in the dimension designer in BIDS go the browser tab of the dimension and make sure the hierarchies are showing up fine.

Related

Calculated Attribute - Min and Max Valid Date

We have some data inside a table (Dimension) with historical values.
Like this (Small example)
ProductId is our Primary Key (and then is unique)
Code is our Business Key
Color and Type are our historical values
In Analysis Services (Tabular mode), our users want to build a report on that values.
Client usage Could be:
(1) If they only want to see the code ('CAR' in our example) the result would be:
(2) If they want to see the code and the Color:
Same for all the attributes that we can have and all the combinations.
Do you know how to solve this?
Can we add some logic in a calculated attribute
Thank you,
Arnaud
In essence, you want to aggregate by date? So, for any set of attributes you put in your pivot table, you want to show the earliest ValidFrom date and the latest ValidTo date that applies?
To accomplish this in SSAS Tabular, import the table and hide the columns ValidFrom & ValidTo. (To hide a column, right click it in Visual Studio and select Hide from Client Tools.)
Then, create 2 measures. For example:
Valid From := MIN([ValidFrom])
Valid To := MAX([ValidTo])
Note the extra space in the names to distinguish them from the column names. You could also call them something completely different. (E.g. Earliest Valid From Date)
When people connect to your cube, people will use these 2 measures rather than the columns from the original table. (They won't even see the columns because you've hidden them.)
If their pivot table includes all the attributes above (Product ID, Code, Color, Type), then the table will look exactly like your original table. If they only show Code, then your table will look like your (1). If they only show Code & Color, then your table will look like (2).

SSAS 2014, relation to time dimension using YYYYMM field. Best practice?

In the process of creating a new cube for my client, I encountered a problem I'm not sure hot to deal with.
I have a table that doesn't have a DateTime field; instead it has a varchar field which contains year and month in YYYYMM format. I need to create a relation to my Time dimension using that field; and proceed with creating Year-Quarter_Month hierarchy.
First thing I did was creating a new named calculation in Time table from the date field to match the YYYYMM format. Now, I understand that the relation can't be created because it would break the referential integrity.
My idea is to create a new Time table/dimension and delete all records except the first day of the month, create a YYYYMM named calculation and then I would be able to create a relation between my table and that new Time table. But, is this the right approach and what downsides I can expect?
Thank you!
You don't need a separate time dimension...when connecting the new fact table to the existing time dimension (in the dimension usage tab) you can set the YYYYMM attribute as the "granularity attribute"...SSAS will handle the rest :-)
Also, if the format is YYYYMM (ie. 201504 for april 2015) then you might consider making it an integer (instead of a varchar) to save some space in your fact table.
You can create a new calculated column in that table to add the first day of the month:
convert(date, YYYYMMfield*1000+01)
and then link it with your key in your time dimension.
This way, your YYYY-QQ-MM hierarchy levels work as intended, if the user is going deeper and wants to see monthly values on a daily basis, he will find all values for that month added to the first day.

How to sort this by month in MDX?

I have never wrote a MDX line by myself, I have been using pentaho and a CDE Wizard to create some charts and it generates this code:
select NON EMPTY({Descendants([NOM_MES].[All NOM_MESs] ,[NOM_MES].[NOM_MES])}) on ROWS,
NON EMPTY({[Measures].[TOTAL]}) on Columns
from [museos_md]
where (${select_museoParameter})
I want to sort that result by a right mohth sequence, because I am getting the months in an alphabetical order. I also have a COD_MES measure that is the correct order of the months, I mean: NOM_MES->COD_MES, January->01, February->02 (coul it be useful?)
The quick solution would be to use
Order(Descendants([NOM_MES].[All NOM_MESs] ,[NOM_MES].[NOM_MES]), [Measures].[COD_MES], DESC)
in MDX.
The correct approach would be to do the sorting in the cube design. I am not sure about Pentaho, but in Analysis Services you can configure the month attribute to e. g. use the month code as key, and the month name as name column shown to users, and do the sorting based on the key. This also affects the display of the attribute as shown to the users, where alphabetically sorted month names are a bit confusing.

How to define which join a dimension is using in ssas

I have a sales fact table with two dates: order received and order shipped.
I have a time dimension table in the data source view.
I have defined two relationships between the time dimension table and the sales fact table, one on order received date and order shipped date.
In the Cube definition I have two dimensions defined: one for order date and one for shipping date.
I have time hierarchy defined for both dimensions (the fiscal calendar).
I can't figure out which relationship either of the dimensions are using. It would appear that they are both using the join to order received date. How do I tell SSAS to use the shipping date for one dimension and the order received date for the other.
Thanks, --sw
I would open the Cube source in Visual Studio / BIDS, then open the relevant Cube object and navigate to the Dimension Usage tab.
Then find the intersection of the Dimension (row) and Measure Group (column) and click the Build (...) button for that cell. That will show you which columns are involved and let you select the correct Measure Group column.
When you first add a Dimension to a Cube, SSAS defines these settings using the Data Source View relationships (if any exist).

Rename Attribute value in Time Dimension in SSAS

I am working on SQL Analysis service to provide ad hoc reporting in my application. I have created a time dimension to use in my cube. It has some predefined attributes. e.g. Month of year. It is having values like Month 1, Month 2, etc. while I want January for Month 1, February for Month 2, etc...
Can any one please suggest me some work around it??
As I am newbie to SSAS, Sorry if I am missing something very silly....
When you work with attributes in SSAS, there are two properties that affect the members of that attribute. The first property - which is set by default when you create the attribute - is KeyColumn. The column that you use here determines how many members are in the attribute because processing generates a SELECT DISTINCT statement based on this column. It's a good idea if you use an integer value here for better performance.
It sounds like perhaps you have a month number for your attribute here, which is good. Except that you want to display a month name. In that case, you set the NameColumn property with the column in your data source view that contains the month name. This produces the label that you see when you browse the dimension.
That said, it's usually not a good idea to have just a month number or month name because you probably want to create a hierarchy to roll up months by year and you won't be able to do that with just a month name. I wrote a blog post describing how to set up a date dimension that might help you: http://blog.datainspirations.com/2011/05/11/sqlu-ssas-week-dimension-design-101-2/