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.
Related
I have a dataset with the structure below.
I want to calculate a monthly average of the views.
I attempted to calculate the yearly frequency with the following code and I believe it is correct
SELECT
EXTRACT (YEAR FROM TO_DATE("date",'Month YYYY') ) AS "year",
AVG("views")
FROM talks
GROUP BY EXTRACT (YEAR FROM TO_DATE("date",'Month YYYY') )
ORDER BY "year" DESC
When it comes to the monthly analysis I have the problem that there several records for the same month in a year and there several years with the same months (in reality the dataset has information for many years - this a reduced version).
How can I go to implement this?
If you want the average per month then just group by your current date field.
If you want the average per month regardless of year then you would have to extract the month part of the current date field and group by that.
But your date field now appears to be having string data type; it would be better to use proper date data type. Then your analysis would be much easier, more flexible, better performing.
I have a situation where the metric calculation(Month to Date Sales) is based on the month from the report date filter.
We want the month to date filter to be for the report month and not the current month - in other words, if the user selects 03/10/2015 for the report date, we want the month sales to be the sales for March,
and not the sales for June.
Is there a way to parse the report date to extract the report month into a variable that can be used in the ‘where' clause of the metrics in order to generate the desired results.
Thanks in advance.
I am not entirely sure if this answers your question, but achieving something like this may be possible when using disconnected timeline date filter. Your metric should look like this:
SELECT Sales_metric BY Month/Year (Date) ALL OTHER WHERE Month/Year (Date) = (SELECT MAX(Month/Year (Timeline)) BY ALL OTHER EXCEPT Date (Timeline))
I hope this helps, in case if it doesn't feel free to log a ticket to GoodData Support at support#gooddata.com.
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.
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.
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.