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.
Related
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.
I have a Month Column with the Month Field populated for each line for the 100K of lines of data I have.
I need to count the amount of times the Month Field is populated in the Previous Month (Period).
I also need to count the total amount of times the Month Field is populated in the Previous 11 months as well.
This is a rolling count for each months reporting that I do..
table name: 'ws pds' and field name [Month Tagged]
You can utilize the powerful time intelligence functions in DAX such as PARRALLELPERIOD to look at values from previous months. But in order to make use of these functions you need to create a calendar/date entity. Mark that entity as a Date table. And join to it by date from your "ws pds" table. The Date dimension should span the timeframe of your date with a continuous list of dates, one row per day.
Then your measure could look like this:
PreviousMonthCount=
CALCULATE (
COUNTROWS ( 'ws pds' ),
'ws pds'[Month Tagged] <> BLANK (),
PARALLELPERIOD ( Calendar[Date], -1, MONTH )
)
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.
Working on an SSAS Tabular project in Visual Studio 2010;
I'm trying to create a measure that calculates the total number of business days in a month:
I have Month Start Date and Month End Date measures, and Date and Is Business Day columns.
I can create a Total Business Days measure with COUNTROWS(FILTER(Dates,Dates[Is Business Day]=TRUE())). That gives me the number of business days in the context, but I want the number of business days for the current month.
I've tried various combinations of FILTER, COUNT, COUNTX, COUNTROWS, DATESBETWEEN, and CALCULATE without success.
What I want is a count of days between two dates, where the column [Is Business Day] is true, but I can't seem to get the right combination of filtering.
I would guess I filter the Dates table the way I do for the Total Business Days measure, but FILTER returns a table and COUNTROWS expects a single column - is there a way to get single column from a FILTER result?
Here's one thought...
First, create a calculated column called MonthKey (if you don't have it already):
=YEAR([Date]) * 100 + MONTH([Date])
Then create another calculated column called IsCurrentMonth
=IF(YEAR(TODAY()) * 100 + MONTH(TODAY()) = [MonthKey], 1, 0)
Then you can create your calculated measure as
COUNTROWS(FILTER(Dates,Dates[IsCurrentMonth] = 1))
Would that do what you need?
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.