SSRS - calculations from different datasets - reporting-services

I am new to SSRS and need help in completing this.
I have a SSRS report which has 2 different datasets Dataset 1 & Dataset 2. In Dataset 2 I have to use a calculation in one of the rows, which requires values from Dataset 2 and Dataset 1. Please see the image attached for the layout of the report and for other details. I would request your help in achieving the orange highlighted fields.

It is generally better to perform these calculations in the query if possible, but it is not impossible to include items from datasets other than the specified dataset for a tablix.
Depending on exactly how your datasets are set up, you may be able to use the Lookup function. This assumes you have a one-to-one relationship between the datasets. You can also sort of trick the function into working for datasets that don't have an explicit one-to-one relationship.
It's a little hard to tell your dataset structure from the information provided, I have a feeling your screenshot doesn't accurately depict your structure. Assuming your datasets are structured something more like this:
+------------------------------------+
| Category | Date | Value |
+------------------------------------+
| Gross Revenue | 2017-08-01 | GR8 |
| Gross Revenue | 2017-09-01 | GR9 |
| Gross Revenue | 2017-10-01 | GR10 |
| Profit | 2017-08-01 | P8 |
| Profit | 2017-09-01 | P9 |
| Profit | 2017-10-01 | P10 |
+------------------------------------+
and similar for Dataset 2, you should be able to use something like this to access the value from the other dataset:
=Lookup(Fields!Date.Value & "Cash Flow Rate", Fields!Date.Value & Fields!Category.Value, Fields!Value.Value, "Dataset2")

in SSRS each tablix object can only have one dataset. what you want to do is not possible using two different datasets. i'll suggest to do all calculations at query level in your dataset2.

Related

Why Facebook Robyn Algorithm needs only unique dates?

My team and I have been exploring the Robyn algorithm to do Market Mix Modeling on my dataset. The dataset is monthly level data of the promotional activity for each customer. In this case the data looks like this-
|Id |Date |Revenue|Channels…|
|-----------|--------|-------|---------|
|Customer 1 |Jan-2021| | |
| ….. | | | |
|Customer 1 |Dec-2021| | |
|Customer 2 |Feb-2021| | |
| ….. | | | |
|Customer 2 |Dec-2021| | |
In this way we have over 1000 customers and their monthly data of the channel activity. We have been able to create models using linear regression to get the impact of each channel. Now when we tried to run this data on Robyn we get a duplicate date error, so does this mean we have to run Robyn algorithm for each customer separately? Then we will have only 12 data points for the model and getting daily or weekly is also not possible for us. Is there anyway to run this kind of data on Robyn? Also why does Robyn restrict us to use unique dates even though it uses ridge regression internally which would not be affected by dates, isn’t having more datapoints better?
About Robyn
You are receiving this duplicate date error because unfortunately, Robyn does not treat panel datasets properly at the moment. You can aggregate the different customer segments in your datasets and run the modeling at a total level which Robyn supports.

How to pull required data from table the way Crystal is pulling it?

I have a view set up like the below table, which is pulling data from multiple other tables using JOINS. Basically I'm trying to replicate a Crystal Report that breaks up the data below into Job # - Weekly (hrs) - TotalToDate(hrs) - Budget(hrs)
And this is broken up per department. The way the report does it is it'll display the hours for the last week, then the total hours to date then the budgeted hours set for that department.
Table doesn't reflect above - just an example of what DB table looks like.
+-----------+------------+---------------+--------+---------------------+
| Job | Work_Date | Work_Center | Est_Total_Hrs | Act_Run_Hrs |
+-----------+------------+---------------+--------+------+--------------+
| 5666 | 2014-02-23 | SURFACE | 155 | 5 |
| 5666 | 2014-02-16 | SURFACE | 155 | 3 |
| 5666 | 2014-02-23 | DESIGN | 200 | 6 |
| 5666 | 2014-02-16 | DESIGN | 200 | 4 |
| 5666 | 2014-02-23 | SURFACE | 150 | 2 |
| 5666 | 2014-02-16 | SURFACE | 150 | 2 |
| 5666 | 2014-02-23 | DESIGN | 300 | 8 |
+-----------+------------+---------------+---------------+--------------+
Also, theres a lot of different job numbers, and when I pull up more than 1 job in Crystal it'll show the report like the picture above but with all jobs I want to retrieve.
How would I go about pulling this data so it shows up the same way in the Crystal Report? I want to create a view that looks the same. Is there a way to see how Crystal does it? When I click "Show Query" it shows me the below query which I had to re-write a little bit for it to work in SQL Server and in Adminer.
Query I'm using to pull ALL data for all Jobs within an updated Work_Date in the last 90 days.
SELECT Job_Operation.Work_Center
,Job_Operation.Job_Operation
,Job_Operation_Time.Work_Date
,Job_Operation.Est_Total_Hrs
,Job_Operation_Time.Act_Run_Hrs
,Job_Operation_Time.Act_Setup_Hrs
,Job.Description
,Job_Operation_Time.Overtime_Hrs
,Job_Operation_Time.Act_Setup_Hrs
,Job.Job
,Job.Description
,Job_Operation_Time.Labor_Burden
,Job_Operation.Est_Setup_Labor
,Job_Operation.Est_Run_Labor
,Job_Operation.Est_Labor_Burden
,Job_Operation.Operation_Service
FROM Job AS Job
LEFT OUTER JOIN Job_Operation AS Job_Operation ON Job.Job = Job_Operation.Job
LEFT OUTER JOIN Job_Operation_Time AS Job_Operation_Time ON Job_Operation.Job_Operation = Job_Operation_Time.Job_Operation
WHERE DATEDIFF(day, Work_Date, GETDATE()) < 90 ORDER BY Work_Date Desc
Crystal will take the data from a query and does its internal manipulation as per the design of the report, So if you need the table exactly as you view the report then along with the query in crystal report you need to make some changes.
Suggestions:
Your report has only 6 columns but you query has more than 10 columns so you need to change the query so that it has only 6 columns.
Report has data according to the week but query has hourly data so you need to write some functions in query so that you manage to get weekly data from hour data
You said when you take more than 1 ID you get in the given format then in that case add some group by conditions to the resultant query so that all data is grouped. for e.g if you need only one ID then group by ID so that there is only one record for a ID.
Try adding some group by conditions some date formulas to get exact output

Hide all middle columns in SSRS

I have a matrix report in SSRS 2008 displaying information about a Company and the total points earned by each company for a selected Quarter.
Example
Company | Current | Previous | Diff |
--------------------------------------
| Q3 2008 | Q2 2008 | |
--------------------------------------
Comp 1 | 2000 | 1500 | 500 |
--------------------------------------
Comp 2 | 1200 | 1400 | -200 |
--------------------------------------
In my SSRS report I have a RowGroup based on my Company field from the data set ([Company]).
And I have a ColumnGroup based on my Quarter field from the data set. Sorting in the group is reversed because I want to start with the latest quarter.
I have parameter for selecting companies and 2 parameters for selecting quarters (QuarterCurrent and QuarterPrevious).
As a side effect if I select 2 quarters that are not consequent I get more than 2 columns which is something that I do not like.
But then I thought that if I could hide the columns in the middle and display on the First (QuarterPrevious) and the Last (QuarterCurrent) I will be able to compare any quarter to any other quarter.
My question is about hiding the columns in the "middle" of the matrix. I am trying to
achieve something like this:
Company | Current | *(HIDDEN)* | Previous | Diff |
----------------------------------------------------
| Q3 2008 | *Q2 2008* | Q1 2008 | |
----------------------------------------------------
Comp 1 | 2000 | *1500* | 1300 | 700 |
----------------------------------------------------
Comp 2 | 1200 | *1400* | 1250 | -50 |
----------------------------------------------------
So in the end I will have only the Current and the Previous columns visible.
I tried the following approaches:
Setting the Column Visibility property to:
=IIF(StrComp(Fields!Quarter.Value,First(Fields!Quarter.Value))=0 OR StrComp(Fields!Quarter.Value,Last(Fields!Quarter.Value))=0,False,True)
In my understanding this should set the property Hide to False to each column that is equal to the First and the Last values in the sequence, and to True to all the others. However it does not happen like this, but all columns were hidden.
I tried setting the same expression to the Visibility property in Group Properties. Still has the same effect - all columns were hiding.
Edit : format code
Instead of two parameters for your quarter selection, have you tried a multi-select dropdown parameter ?
I solved the issue in the following way:
Instead of using parameter with range (From and To) I used a parameter with two values and my queries is not BETWEEN From and To, but rather IN [From, To]. The values of From and To can be any 2 quarters (they can even be switched - From does not have to be before To).

SSRS - Count grouped by Column AND Row in a Tablix

I have an SSRS tablix similar to this:
+----------+-----------+--------+--------+
| Total | RowGroup | Group1 | Group2 |
+----------+-----------+--------+--------+
| Perdiod1 | RowGroup1 | Value | Value |
| | RowGroup2 | Value | Value |
| Perdiod2 | RowGroup1 | Value | Value |
| | RowGroup2 | Value | Value |
| Perdiod3 | RowGroup1 | Value | Value |
| | RowGroup2 | Value | Value |
+----------+-----------+--------+--------+
Now, for each period, I want to calculate the count in each group. When I do:
Count(TableValue.Value, "Perdiod")
I get the total for the period (for both column groups). When I do
Count(TableValue.Value, "ColumnGroup")
I get the total for all periods. So really, what I need to do is something like this:
Count(TableValue.Value, "TablixRow", "TablixColumn")
which obviously doesn't exist.
So 'Value' should be a total count for a group within a Period (therefore, in the example given above, Value would be repeated twice in each Period (once for each RowGroup))
Is there a way to display the count of all the values within a specified column and row group in an SSRS's tablix?
You'd just need to add the aggregate expression to the matrix detail field without a specified scope, e.g. something like:
=Count(Fields!Value.Value)
Since you don't supply a scope, the aggregate will be calculated in its current scope, which for those value fields will be the particular group/period combination.
Edit after comment/update
Hmm... I'm trying to think of an easy way to do this, but coming up empty handed... I mucked around and could get any combination except the one you want.
Basically you're looking for something like:
=Count(Fields!Value.Value, "ParentRowGroup", "CurrentColumnGroup")
and I can't think of an effective way to do this.
Honestly (and it wouldn't be the first time for SSRS) the path of least resistance here is to add the period count you want to display as an extra column to your DataSet when you generate it, then just display this value unaggregated in the detail of the Matrix.
Annoying, but if you can control the DataSet it's a trivial solution to what is a difficult problem at the report level.
=CountRows()
=CountRows("GroupByInitial")
=CountRows("GroupByInitial",Recursive)

Chart reporting in SSRS

I am using SQL Server Reporting to display data using a chart. How do I create my dataset so that the graph displays one line for males & one line for females.
Thanks
Beth
Do you mean two lines as in
one per x or y axis
one per data series
This stupid thing won't allow me to comment so I'm wasting space with an answer
I think what you want is to separate the males and females into different data series. You can go this in the chart properties, as long as you have enough information in your data set.
If your data set looks something like this:
+-----------+-----+-------+
| Date | Sex | Count |
+-----------+-----+-------+
| 2009-01-1 | M | 124 |
+-----------+-----+-------+
| 2009-01-1 | F | 78 |
+-----------+-----+-------+
| 2009-01-2 | M | 95 |
+-----------+-----+-------+
| 2009-01-2 | F | 101 |
+-----------+-----+-------+
Then if you have the Date as the X-Axis variable, Count as the Y-Axis, and add the Sex as the Series Grouping, the it should automatically split them into two graph lines, and add a Legend etc.