Daily, weekly, monthly and yearly reports - sql-server-2008

Am generating a report using SSRS 2008 R2. In my report I have to generate the report daily, weekly, monthly and yearly basis.
I have Date column in my table, i tried to GroupBy this Date, and its working fine, but I need to display daily, weekly, monthly and yearly. How can I group by these . can anyone help me here. Thanks in advance

You can create as many levels of groups as you would like. (There may be some high limit, but four layers of grouping will not be a problem.) Keep right clicking on your tablix and selecting "Add Group..."
Specify your grouping with a VB formula, such as:
=Month(Fields!ColumnA.Value)
Then display this in the group header as:
=MonthName(Month(Fields!ColumnA.Value))

You can use the date part function in reporting services or in your sql logic to give you the data you need for your grouping
=DatePart(DateInterval.Month, Today())

Related

Storing calculated field in a Form for use in a Report

I wanted to store a Form calculated field somewhere so I can use it in a Report.
I understand that it is not recommended to store calculated fields in tables because it breaks rules of normalization.
My DB is basically a simple sum of debits, the sum of credits, and the sum of spendings for many small projects which I want to print a report of at the end of each month. These fields are SUMS so they are calculated fields and the Profit is calculated using [sum of credits]-[sum of spendings].
Should I calculate the Proft field in the Form and store it in the table which the Report is based on. Or should I change my DB design and how would I lay it out?
It turns out that I can do this very easily using the report wizard. I only needed to include both projects table and individual transactions (main Form and its Subform) in the report so a query would be generated.
In the report wizard, there is an option to present summaries of results and one could choose the kind of data summary that needs to be presented. I just chose the sum of the fields of debit, credit, and spending. This option is on the reports wizard Sorting windows under Summary Option ....
When I go into the Design View of the Report, I can rearrange the fields and hide the sections as I need so I would get a one-line summary for each record.

How do I store data pertaining to a month or year in Mysql

I receive csv files at the end of each month from my customer for each of their KPI (for example csv's for resumes received, candidates joined, candidates resigned, sales, profits, loss , etc) for that specific month.
I want to be able to query this data inorder to generate reports for any month, day or year. This report will be generated dynamically i.e the admin would specify what rows he would like to have in a report (for eg a report with applications received, applications shortlisted, candidates shortlisted after the 1st interview for the period of jan to july.) for any period of time.
What would be the best way to store the data into my database in order to generate such reports? I am using Mysql as my database.
I am not sure if I would need to flush out the old data from my tables currently. So considering that I keep all the data persistent, what would be the best suited database design for this?
Currently what I do is I have a table for each of their KPI. This table has got a date field which I am using to generate the report. But I am looking for a more optimized way.
Thanks in advance.
It is better to store those values (month or year related values ) in a "Date" type fields which would not need any other manipulation while building reports. The conditions or logic for the specific period of time should be handled in your front end. In this case, the usage of Date field is the optimized way.

Seperate SSRS report weekly between a date range

I currently have to run a report weekly back to 2014 till now. Is there a way where I can provide it a date range of 4 months and the report can be divided by calendar weeks within the date range?
Any questions, feel free to ask. Thanks
Create a data-driven subscription on the report.
Build a query that returns a table with one row per each set of parameter values you want to run. Assign the columns to the correct parameter and then run the subscription.
If you have specified a file share as the output, all the different versions of the report will output to that share.
Obviously this requires you to provide SSRS access to that file share.

SSRS compare week to the same week number from previous year

I am working on an SSRS report that gets its data from an OLAP cube. In the OLAP cube I have a field named WeekOfYear which gives me the week number of the year based on the date. For example, week 1 for January 1st (if January 1st falls on a Monday) and week 2 for January 8th. My data is grouped by this field but now I want to be able to compare the data from this week of the year to the previous year's week of the year. Like comparing Week 1 of 2015 to Week 1 of 2014. Is there anyway that I can accomplish this? I appreciate any help. Thanks.
There is a LookUp function that should be able to do what you need.
You mention you have a WeekOfYear field. This also assumes you have a Year field (or can calculate it with **YEAR(Fields!YouDateField.Value) )
=LookUp(Fields!YourYearField.Value - 1 & "|" & Fields!WeekOfYear.Value, Fields!YourYearField.Value & "|" & Fields!WeekOfYear.Value, Fields!YourValueField.Value, "YourDataSet")
If you are actually summing multiple rows of data from your cube, you would need to use LookUpSet to get all the values and sum them with a custom function (since Microsoft couldn't possibly envision users wanting to SUM multiple records). Luckily users have already created a function - SumLookup. See How to combine aggregates within a group with aggregates across groups within SSRS if needed.
If you have access to the OLAP cube and can edit this, you could define a new Calculated Measure on the cube. How exactly this would work depends on the set up of your date hierarchies. You can also access this and define calculated measures through the Query Designer while constructing your dataset in Report Builder/Visual Studio.
Right-click in the cube browser and choose "New Calculated Member".
Reporting on weeks across years can be difficult due to the fact that the number 7 doesn't fit neatly into 365 or 366, so you always end up with a little over 52 weeks. Since the 1st of January could be a Sunday one year, and a Tuesday on the next (2012/2013), it's not always a good idea to directly compare these. So people may work around this by defining the 7-day weeks for the year against their date dimension. One year you may have 52 weeks, another you'd have 53. This is a little off topic, so I'll link to an explanation of this here, but it is important to be aware of this in order to implement my suggestion below.
Assuming you have a nice hierarchy on your date dimension that can aggregate up Weeks to Year level, you can create a new measure in your cube using the ParallelPeriod function.
[Measures].[SalesSPLY] AS
(
ParallelPeriod
(
[Dim Date].[ReportingCalendar].[ReportingYear],
1,
[Dim Date].[ReportingCalendar].CurrentMember
),
[Measures].[Sales]
)
My example MDX assumes that you already have a hierarchy called ReportingCalendar created on your date dimension. Yours may be named differently.
Now if you browse your cube and select WeekOfYear, Sales, and SalesSPLY, you will see your value for this year's week 1, alongside last year's.
OLAP cubes are very good at this type of time-based intelligence, as they can very quickly provide aggregated and offset data in a way that would be slower to run in an RDBMS or within SSRS itself.

SSRS Report using SSAS cube - time calculations

I am looking for optimized solution for the below problem -
I have a cube which contains Date dimension which has one hierarchy month->quarter->year.
I have created a cube, all good. Now my ssrs report requires all my dimension customer sales attributes along with the calculations like
last month profit,
current month profit,
last 6 months profit (listing every month),
last month transactions,
last year profit vs current year profit.
As i have created a hierarchy all my calucations for every month and every year and every quarter already pre-calculated in the CUBE. Now to retrieve the above listed calculations, what is the best way to do these time calculations? Where to put these calculations in CUBE or in the SSRS DATASET?
Could you please suggest some good approach and how to do it?
Although it's certainly possible - if you're comfortable with MDX - to write your query to get all these calculations into your dataset, it's usually better for reusablity across many reports to put these types of calculations in the cube. That way, other tools can also use the time calculations if you decide to use Excel or a 3rd party application.
You can use the Business Intelligence Wizard from the Calculations tab to do this - here's an article for SSAS 2005 that's still applicable to later versions: http://www.obs3.com/pdf/A%20Different%20Approach%20to%20Time%20Calculations%20in%20SSAS.pdf
And here's another approach to do something similar:
http://www.bidn.com/articles/mdx-and-dmx/169/mdx-time-calculations-done-the-right-way
UPDATE:
For named sets to handle date ranges like the last 6 months from now, see this article: http://my.opera.com/duncans/blog/using-custom-sets-in-analysis-services-to-deliver-special-date-ranges-to-end-use
not sure if I get you, but the problem is that you need to get dynamic values and you have everything hard-coded?
You can get the previous member in a hierarchy with the prevmemebr function:
([Date].[Calendar].PrevMember, <your measure here>)
where date is the dimension and calendar is the hierarchy.
So if you are browsing by month, it will get the last months data for example
You have to calculate last month profit, current month profit, last 6 months profit as measures in the cube 'calculations' using mdx query. I recently did this for my 'revenue comparison report' where I calculatedlast month's revenue, last2monthsrevenue and priorquarterrevenue and used them. It worked!