Monthly columns in SSRS 2008 from Fetch XML - reporting-services

I have an annual report where I want the months to be displayed in columns Jan-Dec, even for the months that don't have any values.
Today I have a matrix report that starts on May as that month is the month with the first values. But I want the tables to start on January, even if there are no values for that month.
I also wonder if I can have several rows in the same matrix but with different data sources (XMLFetches).
I'll explain a bit more. Really ought to be a fairly simple raport where I want to show how much is sold on a monthly basis and each month is a column and the rows are the products.
i'm using a fetchXML from CRM 2011 on-line.
Month jan feb mar apr may jun jul
Wheels 0 0 0 0 10 65 75
Cars 0 10 0 10 0 100 175

It's not possible to combine different datasets in the same matrix on the report, however, you can combine datasources to create one dataset before presenting the dataset to a report. For example you could use a stored procedure (or SSIS or powershell etc) to read from the database and combine the data into a table, temp table, table variable in the database and then query that from the report - or in the Fetch XML
To get a report that shows calendar entries even for entries that have no data you need to start with the calendar you require and then left-join it to your actual data.
If you are doing this from dynamics CRM and are familiar with editing the FetchXML yourself then you can join data from multiple entities using the with the as appropriate. This other article on stack overflow details that technique: Left join in FetchXml?
For example, if your report has just the months, you could create a calendar table with 3 columns, Year, Month and MonthNumber. The MonthNumber is important for sorting months in the report because you can't order months alphabetically. If you only ever show a single calendar year on the report then the year column might not be necessary but this is something you can reuse for many reports so it's worth doing properly. If you want to read more about them, look up "calendar table", there are many opinions on how to create them, but maybe start with a simple one to get comfortable with the idea.
If you left join the calendar table to your month data, you will get NULL values for the months January to April (because your data starts in May) and you may want to replace these NULL values with 0 or an empty string, depending on what is appropriate. Using isnull() or nvl() or whatever the appropriate function is in your database could be appropriate there.

The answer to how I built the sorting on month is that I used parameters to build up the month-year value for a specific column that I then use to compare with the month-year-value from the fetch.
In the column
=Sum(Cint(IIF(Fields!startmonth.value=Cint(Parameters!year.Value & Parameters!jan.Value),Fields!money.Value,0)))
So the month-year-value from the fetch is via a calculated field built up to e.g. 201302 and that is then compared to the selected year 2013 and added the monthvalue for that specific column 02=201302.

Related

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.

Database structure for variable column names [duplicate]

I am writing a script which will counts the number of ticket as per as different conditions and store the count in a summary table. I am unable to understand how to structure my table since there will be more than 1 variables.
The script will run every week and with each execution a new week will be added. Once the new month starts and scripts execute, a new month will be added and once new year starts a new year will be added. So in a nutshell I have columns which are also variables. Not sure how to handle it and structure my db.
Have columns Date Service Count.
Like so.
Date Service Count
16 May 2016 Service1 35
Then when you go to display them in the report pivot them as you want. Probably better to make date an INT and either an auto number PK or composite PK of Date and Service.
Wrong approach. Do not splay an array across columns. Instead have rows for the data. This lets you trivially "add" another month.
For displaying, well that is an application problem, no a MySQL problem. Sure, you can write specialized queries to "pivot" the data from rows to columns, but it is messy.

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 2012: Sparkline Chart Per Every Details Row

I have a stored procedure that returns data in this format:
Location MorningSales NoonSales NightSales
A 12 6 32
B 20 43 12
I have my table displaying the above data in details (not grouped) format. I now want to add a sparkline at the end of each row, using the numbers in those three fields.
They should look something like this:
I just cannot for the life of me figure out how to setup category groups for each field.
I was able to have this result before by bringing in the data as multiple rows for each Location, i.e.:
Location SalesTime SalesCount
A Morning 12
A Noon 6
A Night 32
B Morning 20
B Noon 43
B Night 12
But for the purposes of speed, I had to pre-calculate my sums and avgs in a stored procedure, since SSRS seemed to take forever and a day to render the report when it calculated the aggregates itself.
Is there any way to pull off what I'm trying to do here?
I think my question is similar to this one:
SQL Server Business Intelligence Studio: Line chart from single record
The accepted answer there is to rewrite the sql query and end up with something similar to the second dataset I showed here. If it can't be done any other way then fine, but I don't mind hacking and rigging to make it work for my situation.
Hope below link helps you in finding the solution:
http://www.sqlcircuit.com/2012/11/ssrs-how-to-add-sparkline-in-tabular.html

Saving reports query to database

I am developing an web app that is reliant on reports being dynamically generated. The client has specified they would like to save reports searches to the database for future use, specifically generating reports from the last 6 month.
I can add the query to the database no bother, the problem is trying to get the date to be dynamic depending on the date the report is ran. The 3 types are bi-monthly, monthly and 6 monthly reports.
My question is:
How would I go about saving the query and getting it to calculate the current date and search based on the report type (2, 3 or 6 month). Is it a simple case of editing the sql query when I pull the query from the database, or would it be easier to split up the query into different parts to make it easier to manipulate/edit later.
Create a second column in your table where you store the query with the dynamic column. Use that column in your dynamic query