Performing MTD/YTD calcs over multiple calendars in analysis services - ssas

I have the following situation in my cube:
Shop A uses calendar Cal1. Their sales month starts Jan 5th.
Shop B uses calendar Cal2. Their sales month starts Jan 10th.
Shop C...etc
Shop calendars can not simply be represented as offsets of a main calendar. They have different working days, public holidays etc.
I need to produce a daily (reporting services) report with the actual calendar date as a parameter. The list of shops is also a multi select parameter. If a user selects the 15th of Jan, I need to show the combined MTD sales for all shops selected in the parameters. So that would mean the first 10 days of sales for shop A and the first 5 days of sales for shop B etc.
Any ideas how I can make this work? I'll also need to provide YTD figures in the same manner.
I am implementing multiple calendars using a bridging table between my date and calendar dimensions. It is the technique described here: http://duncansutcliffe.wordpress.com/2010/06/11/a-better-date-dimension/
I can not hard code the calendars as there is a requirement to possibly add more in the future without modifying the schema.

I am not sure I understand you sales data start days, but if I do then the solution is to make an extra dimension as a "reporting calendar" as a point of harmony between the actual calendars
Each shop has a known offset to the reporting calendar, so for shop A it's 5 days, for shop B it's 10 days etc
When you add fact data you also need to calculate a reporting date using the offset. So for Shop A 5 Jan is actually 1 Jan etc
When reporting, the user selects a date on the reporting calendar, and facts are selected based on that
e.g. if the user selected reporting calendar 15th Jan, it would only select actual dates 1 to 15 Jan and reporting calendar up to 15 and only Jan
Data selected would be Shop A 5 to 15, Shop B 10 to 15
1 to 4 Jan for Shop A and 1 to 9 for Shop B would be in Dec of the reporting calendar, and not included because of the filter of reporting calendar Jan

Related

I need to write an .sql query that shows data aggregated at the monthly level looking back over the past two years

Right now the problem with my code is that it counts each month as a new aggregation, meaning that January and February will contain activity for the same account in both months. I only need the monthly activity for each month at the level of each account.
Right now where for example the activity for Account A = 100 for January and activity for Account A = 25 in February, my query shows activity in February for account A as 125 when I would like it to be returned as A = 100 for January and A = 25 for February.
Is this clear? If I use for example (YEAR(date_column)) the aggregation at the annual level is accurately represented. This approach however does not allow me to provide a monthly breakdown of the data. If I add a second column to get the "Month" values from the date e.g: (MONTH(date_column)), the numbers are aggregated month over month and not at the month level alone.

SQL - SUM two columns with a date range on one of the columns

First off its been a long week and I'm having a moment e.g. I just can't figure this out but I know its straight forward.
I have a CTE with a query for a GL Detail and one for Budget which are bought together to display all the details needed for a report.
For example the GL detail bring back the actual amount from a date range such as 2019-01-01 and 2019-04-01
and the budget part brings back the budget for each month so the date range is 2019-01-01 and 2019-12-01 as I need to sum up the total budget in a report.
Using an iif expression in SSRS the report shows the actuals up to the month a user select (there is on a to_date parameter)such as April then the report shows actual from Jan and then budget from May to Dec. I need to show the total of budget for the 12 month which is straight forward as I have bought each month amount back.
My question is I need to sum the GL actual amount for the months selected in by the user Jan to April and the remaining budget amounts May to Dec. For some reason I just can't work it out in my head.
Edit - I'm using
postgresql
SSRS - Microsoft SQL Server Reporting Services
columns are in GL is gldetail.amount and for Budget budget.amount_budget - I have a column in both gldetail and budget queries which is called post_date.
Worked it out -
,case
when src.post_date <= src._to_date then src.amount
when src.post_date > src._to_date then src.amount_budget
end as actual_budget_total
Then in the report sum the actual_budget_total

Forcing rows to appear despite data missing

I have a large data set (called input below) which contains a variety of information such as sales dates, transaction dates, payments, sales.
The user can produce a report by year, quarter or month to show the amount of payment in a particular month/quarter/year of a certain sales year. So you could have a payment 5 years after the initial sale, i.e. a payment in 2016 relating to the sales year of 2011.
The user can decide whether they want to have these payment periods by month/quarter/year at the beginning of the code through the use of macro variables (i.e. %let ReportBasis = Year) and ReportBasis can be called on through the rest of the code without manual adjustments.
The report is produced using:
proc sql;
create table report as
select sales_year, &ReportBasis, Sum(Sales) as Sales
from input
group by sales_year, &ReportBasis;
quit;
Now the issue I am having is that if there is no payment in a particular period for all sales years in question, then there is no row for that period. This produces a layout problem.
I require a solution to this which can be dynamic due to the nature of the macro variable (changing from year to month to quarter).
So I have this (example):
2011 Month 11 100
2011 Month 12 250
2011 Month 13 85
2011 Month 15 90
2011 Month 16 300
But I require this:
2011 Month 11 100
2011 Month 12 250
2011 Month 13 85
2011 Month 14 0
2011 Month 15 90
2011 Month 16 300
where there is no actual payment in month 14 in all of my data (even other years 2012, 2013 etc.), so it doesn't show up in my first table, but the second table still cleverly knows to include it.
Thanks in advance.
Here is one solution that assumes that all years and reports are represented in input, although not all combinations:
create table report as
select sy.sales_year, r.rb, Sum(i.Sales) as Sales
from (select distinct sales_year from input) sy cross join
(select distinct &ReportBasis as rb from input) r left join
input i
on i.sales_year = sy.sales_year and i.&ReportBasis = r.&ReportBasis
group by sy.sales_year, r.rb;

OBIEE Moving Average Drill Down

I have created a graph to show 6 months moving average column for last 13 months
Now users want to drill on these 6MMAs for last 6 months data contributed to that moving average.
Say , for Mar 2016 the contributing months are 10/2015, 11/2015, 12/2015, 01/2016, 02/2016 and 03/2016.
So when user clicks on Mar 2016 data point they should see all contributing projects for that month i.e. 10/2015, 11/2015, 12/2015, 01/2016, 02/2016 and 03/2016.
For Feb 2016 the contributing months are 09/2015, 10/2015, 11/2015, 12/2015, 01/2016 and 02/2016.
So when user clicks on Feb 2016 data point they should see all contributing projects for that month i.e. 09/2015, 10/2015, 11/2015, 12/2015, 01/2016 and 02/2016.
And so on..
How can I achieve this?
Create one more analysis which will show data for all months/year.
And create a drill down from your master report which will be navigated to the detail report .
Also on what column basis you want to display your detail report ,give "column as prompted " there.It will be like "Master-Detail" analysis.
So when you will click on master report,that value will be passed as a parameter to detail report through "is prompted".And required value will be displayed.
PFB the link for detail explanation.
http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/bi/bi1113/actionframework/actionframework.htm
Hope it is helpful.
you can try a work around.write a formula in your month column in your detail report. --Extract year from the presentation variable and month should be latest value of the month column and (month-5).Try with this. Try to create the detail report which will basically show the last 5 months data.and pass the variable accordingly. – mona16 12 mins ago
try some thing like this in your date column in detail report. use filter on you date column Time.Date <= cast(current_date as date) and Time.Date >= TIMESTAMPADD(SQL_TSI_MONTH, -3, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))

Selecting columns based on date in Sharepoint

I am very new to Sharepoint. I am working on a resource utilization list in Sharepoint , which helps managers keep a tab on utilization of their resources for each month . My list therefore has 12 columns for each month of the year. I want to create a view where in only the future 5 months from the current month are displayed. Therefore for example if the current month is August, I want only August,September,October,November and December columns to be displayed and the other month columns hidden.