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

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.

Related

Cube Calculation - MDX - Compare Date to Another Date from Date Dimension

I am trying to create a calculation measure to compare revenue from one date to last year's equivalent date.
I have this "last year's equivalent date" stored in my date dimension.
So for example, my fact table of DailySummary has a measure of TotalRevenue and it is granular by date. If I wanted to show today's revenue (12/06/2019), the equivalent date from last year that is stored in the Date dimension would be 12/07/2018. I would want to show both those day's revenue side by side. I would then create other measures, like growth.
I am sure it is obvious, but if it helps, the DailySummary fact and the Date dimension are joined by the date, so today's date, not the last year equivalent.
Let me know if this doesn't make sense or if you need more information.
I think that you will need to use the PreviousPeriod MDX function.

Creating a calculated measure to display prev month value

I have a cube(multidimensional) in SSAS which contains a dimension with a period hierarchy(year, month, periodcategory, periodcode) and a measure "Amount"
Now i try to make a calculated measure which returns the value Amount for the previous month - value Amount for the current month (this will then only be different from the current amount when drilled down to month in the period hierarchy).
I read a lot of posts already about ParallelPeriod function or lag(1) but i don't see how this could help me in this case.
Any advice would be really helpful.

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

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!

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.

MDX Calculated Measure - counts between start and end dates

I have a dimension "Company" which has a member "CompanyName" and a measure group "CompanyMembership" which has measures "StartDate" and "EndDate". How do I count the number of companies that have membership for a date or month or year? I also have a user hierarchy Date.Calendar (like the one in Adventure Works).
If the date current member represents a month the member value will be the first day of the month and I only care if the membership covers that day. If a year the member value will be the first day of the year and I only care if the membership covers that day.
Here is some pseudocode for what I would like:
sum( if (Measures.StartDate <= Date.Calendar.Value <= Measures.EndDate) then 1 else 0)
I would like to keep StartDate and EndDate in the same fact table row (not split into two rows - one with StartDate and one with EndDate) but would be willing to change the schema if there's no other way.
How can I write this expression?
I don't have a method for doing this in your current schema, but you should really consider making Membership a time dimension. That would make answering "was this company a member on this date?" much easier.