SSAS, how to make Dimension Attribute Month only show the months in current year? - ssas

In our date dimension, there are Month and Year attributes. Month attribute has set int month_year as key, to avoid duplicate problem, and Month attribute has name like January, February...
Now there is problem, if user drags Year and Month to filter, and would define one year, say 2017, he expect to see Month Attribute in filter only shows 12 month names in 2017. However, Month Attributes shows month names for all years, the names repeating many times.
There is already calendar hierarchy built in this dimension. But the user wants to define filter outside of hierarchy. How to build such Month Attribute in cube? Does some one have any idea about it? Thanks in advance!

The problem has been solved. Just add a new column in date table, say Month_in_current_Year, has the same content as Month column. Add this new column to date dimension as a new attribute. This new attribute works for my purpose. It shows only 12 elements as months in one year. And it slices correct value while setting it to filter. What magic is the cube!

Related

Pass parameter to MDX/Tabular Object Model Cube using tableau parameter/filter

I have below things:
Tableau report (with Year and Month)
The tableau report is pointing to Tabular Object Model Cube
Tabular Object Model contains date dimension, region dimension and fact sales
Trying to achieve below:
When the user selects a year and a month from the report, the report should give me sales for previous 3 quarters with reference to the month selected
If your solution proposes to use a MDX query, then it would be great if you can point to some link, to illustrate how this can be done.
I have tried below:
Dragged Year and Quarter in rows(in tableau) and dragged the calculated field in column. This gives me sales across all quarters for all years but I want to limit this information to previous 3 quarters based on the Year and month selected by the user.

Adding a fact table with start date and end date to a multidimensional cube

I have a fact table with payroll data and contains columns such employee id, dollars, start date & end date (pay period). So the granularity is not at the daily level. How can we add this fact table to my cube and link to date dimension? I have a date a typical date dimension in the cube with date, month, quarter and year.
note - the start and end date do not always fall on the sames days of the calendar month. I know it is terrible idea to somehow "convert" the grain to daily level by diving the dollar amounts by the number of days between start date and end date but i can't figure out another/better option.
As explained in the documentation, a relationship of a fact table/measure group to a dimension need not point to the key attribute/column of the dimension, it may point to any attribute (like the month attribute in your case). Then, you only can use the attribute that you linked to and attributes which have direct or indirect references from it. If you would have a reference from month to quarter and from quarter to year in your dimension, then the measures from your measure group referencing the month attribute can use quarter or year. But they cannot use days.

how to summarize sql result, week and month wise in single query

I want to summarize sql query result week wise and month wise at the same time in a grid view. Is this even possible or I am just dreaming?
Requirement:
Show last one month data and next two month's data week wise in the grid.
Example-
If the current month is September then I want to show data from 1st August to 31st October categorized in weeks.
Show the data after the next month of current month in month wise view in the same grid.
Example-
data for month November and December will be shown categorized in month not in weeks.
grid or result should look something like below -
Please suggest something to achieve this
If you want a maintainable solution, use two independent queries, one for weekly aggregation other for monthly. Depending on the input run corresponding query.
I think you must work with group by or group by ... cube
SELECT x , y from <tabel> GROUP BY date_feld( to_char( 'MM' ))
but i don't now your DBMS so i can't give you a exact example for the date handling.

How to get month within a range vb2010

I just don't know how to go about this.
I designed a program that uses MS Access as its database. I have a field for month and year (the field data type is text) where user can register details. The program will register the month and year the user have chosen e.g month= September, year=2011.
My problem now is how to chose a range of data to view by the user using the month and year as a criteria e.g the User may want to view data range from (September 2011 to July 2013).
I couldn't figure out even how to try. Help will be highly appreciated.
Perhaps you could change your application logic to store the month and year as their respective numbers rather than text and change the field data types to numeric.
You could then construct a DateTime object from them, for example September would be 9 and you could use code like the following:
var startDate = new DateTime(year, month, 1); // get year and month as integers from database, uses the first as the date
var endDate = new DateTime(year, month, 10); // change the date but keeps the month and year the same
var endDate2 = startDate.AddMonths(1); // adds 1 month to the date
Alternatively, you could try using a calendar control to allow the user to select two dates instead of building it from a number of fields. Depending on what you are using this could be achieved a number of ways, for example in ASP.Net or WPF you could use two calendar controls and just use their SelectedDate properties as your range.
A range is from a startpoint until an end point. For the startpoint you can add automatically the first of Month. For the endpoint is it more complicated because there is no fix endpoint. What you can do is following:
Write an array that contains for each month the days (e.g. 30 or 31). Except for Febrauary there is a fix pattern.
for Febrauary use the selected year to check is the year a leap year or not. If not add 28, else add 29.
After that create the date string for your SQL:
Startdate 1.9.2011. Do for the entdate the same.
After that, I think you can use the keyword between in your SQL query.
You can assume that everything is entered on the first day of each month. I would pull the information using a query to the database.
select * from [tablename] where DateSerial([colYear], [colMonth], 1) between DateSerial([fromYear], [fromMonth], 1) and DateSerial([toYear], [toMonth], 1)
In this question are some ways to do this:
First. Filter the dates in a range assuming that you use a date like '07-12-2012'
i.e. September 2011 to July 2013
Where DateColumn > '09-01-2011' and DateColumn < '07-31-2013'
OR
Specify a Date and a Year
Where month(DateColumn)='1' and year(DateColumn)='2016'
Note:
There are many ways to do this.
You can Manipulate your statement depending on your desired output.

MDX Sum values of lower level

I am new to OLAP, I just designed my first cube and now I am trying to make some simple analyses. I have a simple time dimension that looks like this:
- Year
- Month
- DayOfWeek
Now I would like to sum all measures for e. g. Monday. I don't want to know the measure for Monday for every month of every year seperated (I am able to do this) but for all Mondays ever. Just one value.
Is it possible and if, how?
Thanks!
Time to break out the AdventureWorks sample and look at their time dimension. You need more attributes on your dimension. There should be attributes for Year, Month and Date that are arranged in a hierarchy, but the attribute for DayofWeek, MonthofYear, etc, should be separate if you need to aggregate on them.