Dynamic number and ranges of graphs in SQL server report services - reporting-services

I need to create a report for a process that spans from time t1 to t2.
In the report I need to have number of graphs, one for every 4 hours of the process, for example if t1=9:30 and t2=20:17 I need three graphs in total, one from 9:30 to 13:30, one from 13:30 to 17:30 and the last one from 17:30 to 20:17.
The timespan, and thus the number of graphs, is theoretically limitless.
How can I do that?
Im using visual studio community 2019, and my data is from an sql server 15.0.2 that I can change freely.

Related

Power Bi Report Builder - Calculating change from last year

So I have 2 datasets. One is stats for year 2022, one is stats for 2021. I want to compare the numbers (totals) for each year in each category. I did this by creating a tablix using the wizard for each dataset. The last column is a measure imported from the data set and it calculates the percentage change from the same total in the previous year. As you see everything matches except the totals highlighted in red. For example, Full-Time Domestic is 18 in 2022 which is down 66.67% from 2021's number which is 54. This is correct, however the total: 284 in 2022 is not down 74.31% from 2021; It is summing the changes. I tried removing the sum() function but it just returns the first number (-66.67%) instead of the actual change. I'm still fairly new to power bi and report builder so I'm not sure how to fix it. I've blurred some info for privacy reasons.
Screen Shot of Tablix

How to effectively store data of varying time framces

I have a form that captures production data for a certain process. When a employee enters production numbers, currently I am not sure what the time frame for the production numbers are.
E.g. Employee A enters a production number of 50 on 2017/10/02. This 50 represents the production of 1 day (2017/10/01). Now, employee B enters 550 on 2017/10/03, but this represents production for the week of 2017/09/24 to 2017/10/01.
Now, we know that various employees will be providing data of different time frames, but I'm trying to figure out the best way to manage this. I capture data using a Excel sheet with VBA, and then transfer it to a SQL database. Currently, in the database we use GROUP BY to get all data related to a certain month. So if the timestamp of the data is in September, all September data will be summed and the total used as the September total to date. However, this does not answer two key points:
If data for September is entered in October.
If data is entered that duplicates a period for the employee that was entered earlier.
What is the best way of managing this? I can change my capturing form and the way we manage data in the database.
EDIT and more information:
The information I want to capture consists of production numbers from various production areas entered by an employee. So for example, site A will have 3 sub-sites. These sub-sites will each have a production achieved, target for the period and forecasted production number.
Timestamp: Site: Sub-site: Production: Target: Forecast:
2017/10/01 PlaceA Line1 200 250 230

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

Monthly columns in SSRS 2008 from Fetch XML

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.

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!