Rename Attribute value in Time Dimension in SSAS - 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/

Related

Edit 'no value' in crosstabs - Cognos Analytics dashboard

Is there a way to edit the 'no value' in the cells of a Cognos Analytics (11.0.13) dashboard crosstab visualization? I would like to change it into 0.
Thanks in advance.
My answer consists of two parts.
The first is of some techniques to do what you want to do. The second is of a caution about you really really need to understand the data to know if the values should be reported as zero rather than null.
Part the first
It depends on your data source and the provenance of the object.
If you are using a data module you can set a setting for the query item to replace the null with a zero.
If you are using an expression you could use the coalesce function to substitute a value then the source value is null. This could be used in place of whatever measure you are trying to use in your chart.
For example coalesce ( {some query item}, 0)
Coalesce takes any number of parameters and will return the value of those in the leftmost position unless it is null and then return the value for the next parameter, unless it is also null etc.
I'm assuming that you are using a file directly in the dashboard. My advice is that it might be a good idea to put it into a module, do your modelling there so that it is available in all your dashboards and reports and you can use it in conjunction with other data sources. Also, if you have a multi-sheet or multi-file source you have the ability to know how the relationships between the sheets were defined and correct them if need be. I have not had entirely good experiences with the soi disant smart relationship generation in multi-sheet files but you're using 11.0.13 and I don't think it's in there. (I'm using 11.1.5)
Part the second
For purists out there: A null is not a zero. There is a difference between a null and a zero. It's difficult for people without maths degrees (such as me, who trained as an accountant) to understand that but I have a fairly simple example which I think can show where a value is null and where it could be truly zero.
Assume that you are doing a month by month sales report for a car dealer. This time last year (i.e. in April 2019) you could be selling 2019 model year cars and some 2018 model year cars. You were not selling any 2020 model year cars because they were not released yet. In that case, the value ought to be null. Over time the number of sales of 2018 year cars would possibly be 0 as you would no longer have them in inventory to sell. In this pretend report I have a sale of 1 2018 car in February of this year.
Now, your report for 2019 will have nulls for the sales of 2020 year cars before the autumn (I think that's when they usually release new cars).
It is possible that the number of sale for April this year will be zero.
#E. van Dongen,
There is a way to set 'Missing value characters' property to '0' on Col Format option in CA 11.1.5 version. This option may be available in CA 11.0.13 as well.

Filter SET by currentMember.MemberCaption

I have a SET of members of some dimension, let's say [Dim].[Dim].[Dim]. Then I wrote a query that returns all the elements from this dimension for 2016 year of some measure, let's say there are 5 of such.
The next step that I want to make is to find first one member in this dimension with the same name (as CurrentMember in row) but for 2015 year. As result, I want to calculate some measure with regards to 2015-member, not 2016's.
So the problem is in scope - I can't GENERATE such set because CurrentMember's function scope will be equal to GENERATE's scope so I am unable to extract actual current member that is on row now and for which I want to find "same previous by name" members.
Am I able to do this with plain MDX or should I go with some workaround like finding such "same" elements in t-sql view and making child-parent relations in cube by hand? The second approach I think is very undesirable and ugly.
Thanks.
Is there a reason you can't just use .PrevMember on the Time (Year, I guess) dimension?
WITH MEMBER [Measures].[SomePrevYearCalculation]
AS ([Time].[Year].CurrentMember.PrevMember,[Measures].[AMeasure])
SELECT
{[Measures].[AMeasure],[Measures].[Some2015Calculation]} ON 0,
[[Some complicated dimension stuff]] ON 1
FROM Cube
WHERE [Time].[Year].[2016]
Or are you dealing with a dimension that has multiple duplicate Names at leaf-level, so that you can't match the 2015 to 2016 figures by the actual dimension member?

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.

Why data is repeating in ssas dimension

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.