SSRS Stacked Column Chart - Multiple column overlap - reporting-services

In SQL Server Reporting Services 2008 R2, I have the following dataset.
Date | Value 1 | Value 2
--------------------------
Week 1 | 52 | 57
Week 2 | 49 | 63
Week 3 | 88 | 71
I have a Stacked Column Chart with the X axis of Date, and the Y axis of Value. The columns in the chart currenly shows Value 2 on top of Value 1. This shows the column as the total of Value 1 and Value 2. So for Week 1, it is 109 etc.
Now my question is, how would I get the chart to show the total of each column to be the highest Value in the dataset? This would still show both values but would have the entire column of the lowest value with the remaining value on top. So for week 1, the total would be 57. The column for Value 1 would be 52 and the column for Value 2 would be 5.
This may be confusing so I have added a dummy image of what I intend the final graph to look like.

Maybe you can write a query like this:
SELECT LEAST(value1, value2) as value1, GREATEST(value1, value2) as value2
value1 < value2 as color
FROM ...

Related

Repeat group header in SSRS

The report output needs to be in the following format:
Group Header - Date1
Col1 | Col2 | Col3
------ ------ -----
aa 11 11.11
bb 22 22.22
cc 33 33.33
next page
Group Header - Date2
Col1 | Col2 | Col3
dd 44 44.44
ee 55 55.55
ff 66 66.66
Question
Data will be displayed as part of Tablix with date(group header) as Rowgroup.
I need to display the columns as well as the Group header which is a date variable. The data is grouped by the date in the group header.
How do I display group header in SSRS?
Thanks
>
Update: Trying to achieve similar to SSRS Tablix - Each group as group header row
but with page breaks in between.
While adding a totals row, the row is inserted below the column headers. So I deleted that and inserted a row above the column headers and set the column to row group (In the example, Dept). But the value of the row group is not changing for the next set.(Math to Biology in the example) It seems to be stuck to the first value for all groups. What did I do wrong?
Create a tablix(table) with a group on date (gray row) and detail (white rows).
Set the group expression to your date field and set it to page break between each instance of the group.
Be carreful for the group value to be a simple value Fields!mydate.value and not something like First(Fields!mydate.value)
Add a group line (not new group) below the date header for the column headers (blue row)

how to get max of column values in a row in ssrs matrix report

I have created a SSRS report which shows Hours as column names and dates as row names. Cell values represents the Sales of a specific hour of a specific date.
the table in my report is as follows:
Date |Hour 1|Hour 2|Hour 3|max sales|min sales
4/10/2015| 5 | 10 | 15 | 15 | 5
4/11/2015| 30 | 10 | 20 | 30 | 10
I want Green color background in cell with max sales and Red color background in cell with min sales. the required output will be as follows:
Date |Hour 1 |Hour 2 |Hour 3 |max sales|min sales
4/10/2015|5(Red) | 10 |15(Green)| 15 | 5
4/11/2015|30(Green) |10(Red)| 20 | 30 | 10
I have written a custom code for GetColor as follows:
Function GetCellColor(ByVal minValue As Integer,ByVal maxValue As Integer, ByVal currentValue As Integer) As String
If currentValue = maxValue Then
return "Green"
Else If currentValue = minValue Then
return "Red"
Else
return "WhiteSmoke"
End If
End Function
which returns color based on cell value. I can not pass the maxValue, minValue of a row.
Thanks in advance.
You should be able to accomplish this the way you are doing it but you'll need to use the same field or expression that you use to populate your Min and Max columns in your Code call. If you use an expression to calculate it, you would use the same formula.
=Code.GetCellColor(Fields!Max_Sales.value, Fields!Min_Sales.value, Fields!YourField.value)
As Koryu mentioned, you can accomplish this without using code by putting the logic in the Expression for the background color property:
=IIf(Fields!YourField.value = Fields!Max_Sales.value, "Green",
IIf(Fields!YourField.value = Fields!Min_Sales.value, "Red",
"WhiteSmoke"))

SSRS - Returning the average where date is 2015

I have been trying to figure this out for a while now and just couldn't find the answer anywhere.
I have a report in SSRS with a column group assigned to "Year", this column expands depending on what parameter the user enters into StartYear. If the user enters "2013" the report will extract all data from 2013 to 2015, this means that there are then 3 columns with the same name ("Cost").
My report looks something like this when entering StartYear as "2013" the value beneath "Year" displays the "Cost" column :
Area | 2013 ("Year") | 2014 ("Year") | 2015 ("Year")
A | 20 | 50 | 25
B | 15 | 65 | 35
C | 40 | 70 | 20
Before the report get built, the reports looks something like this:
Area | [Year]
[Area] | [Cost]
I want to add a column to this report which displays the Average but only for the Year 2015.
This is what I have tried sofar but it brings back the Average for one row and all the year : 20, 50 and 25 instead of 25, 35 and 20:
=Sum(IIF(Fields!Year.Value = 2015, Avg(Fields!Cost.Value), 0))
Any help would be greatly appreciated.
You need an expression like:
=Avg(IIF(Fields!Year.Value = 2015, Fields!Cost.Value, Nothing))
If you are using an IIf expression to get a subset from a DataSet, you must specify Nothing as the False part of the expression, otherwise you just get a bunch of zeroes included in the aggregate, skewing the results.
This assumes the aggregate is running outside any particular Group Scope - you can always add a Scope to the expression to make sure you are checking the entire DataSet:
=Avg(IIF(Fields!Year.Value = 2015, Fields!Cost.Value, Nothing), "DataSet1")
Edit after comment
To expand on the Scope comment above, you can specify the aggregate to run at the Row Group level by adding the Row Group name as a parameter to the expression:
=Avg(IIF(Fields!Year.Value = 2015, Fields!Cost.Value, Nothing), "Area")
Assuming Area is the name of the Row Group.

Grouping by Dates

I have a report that displays the date on the left column (mm/dd/yyyy) and data that corresponds to each day on the right column. For example:
Date | Number
1/2/2014 | 10
1/5/2014 | 4
1/17/2014 | 22
2/1/2014 | 2
2/13/2014 | 14
3/3/2014 | 1
How do I group the dates together by months so it will be displayed like this:
Jan 2014 | 36
Feb 2014 | 16
Mar 2014 | 1
First we create a table as you already have.
At the bottom of Report Builder there should be a footer that says: "Row Groups" and your date row should be in there.
Right click on the date group and select group properties. Under general it should already have a group expressions relative to "Date". Click on the Fx button to the right and edit the expression so that it says:
=MONTH(Fields!your_column_name_here.Value)
instead of
=Fields!your_column_name_here.Value
That should group by month. If you want the date formatted in a specific manner right click on the text box for [date], go to "text box properties", then "Number", select "Date" from the "category" menu and select the format you are looking for.
Make groupings by = Month(Fields!Date.Value) & Year(Fields!Date.Value)
(use them year first if you want the values to be the sort, for correct ordering)
Then For the labels, you need to use MonthName and the integer of the Month:
=MID(MonthName(Month(Fields!Date.Value)), 1,3) & Year(Fields!Date.Value)
Here I also took the Md of the month name, its first 3 characters, Jan Feb Etc.
In the grouping make your counts =Count(Fields!Item.Value)

Define Column Values and relevant values Populate data Field in SSRS

I am Trying to do a Matrix Style Report , where the Rows get Populated from the Query.
Can we Give Values in the Column Field(These are Row Values from the Query) and the data gets Populated from the Query itself.
Why I want to do this is, the query does not show the row if the Value that I want to display in the column field on the report is Null. And Hence in return cannot Display it on the report if the Query itself Does not have the value.
Now there are No values for any member in the Group, the transfers field will not show up. But it has show with a value 0 in all the columns with Row Members.
EDIT:
My query returns a table like this . Parameter: 'YEAR'
Group Group_Items EMP_ID Status
Group1 Alpha 1 Continuing
Group1 Alpha 2 Continuing
Group1 Alpha 6 Continuing
Group1 Beta 8 First Time
Group1 Beta 11 Continuing
Group1 Gamma 14 First Time
Group1 Gammma 15 First Time
Group1 Gamma 10 First Time
Group1 Zeta 12 Continuing
Group1 Zeta 23 Continuing
Group1 Zeta 44 Continuing
Group1 Zeta 56 First Time
So I want to know how we can put this in the BI and count(Emp_ID) according to First Time, Transfer and Continuing. There is transfer value sometimes , but have to show it all the time and if no values come up we have to show it as 0
You could check for NULL/non-existent values in the transfer cell by using an expression like:
=IIf(IsNothing(Sum(Fields!Transfer.Value))
, 0
, Sum(Fields!Transfer.Value))
This will display 0 if there is are no values in that row/group or they're all NULL.
More logic can be added to the first section of the IIf statement if required.