Hiding "Series1" from chart legend when values are null - reporting-services

I have a chart that needs to show all months of the year even if they do not contain any data. Problem is, my legend displays these null records as "Series1" on my legend.
Is it possible to get rid of the "Series1" from the legend? I've tried creating a custom legend to hide any values that are null but I'm running into issues.
Here's the syntax I've tried:
=IIF(ISNOTHING(Fields!Type.Value), NOTHING, Fields!Type.Value)
Here is the data that is coming over. Any NULL values for the column "Type" are showing on the legend as "Series1" while the other values show as they should
MonthNumber MonthName Type
1 Jan NULL
2 Feb Value1
2 Feb Value3
3 Mar Value2
3 Mar Value1
4 Apr NULL
5 May NULL
6 Jun NULL
7 Jul Value3
7 Jul Value1

finally found a solution in Visual Studio 2019.
Using "Chart Data" context menu, choose right-click context menu of Values series being used (box next to sigma sign).
Choose "Series Properties..."
Choose Legend then the function against "Do not show this series in a Legend".
i.e.
Series Properties > Legend > Do not show this series in a Legend >> Function
-> Expression:
Then use the following expression;
=IIF(Fields!Type.Value IS NOTHING, true, false)

Related

How to access counts to calculate the difference in a SSRS matrix with column and row groups

I’m building a report in Visual Studio 2017 (SSRS) and it uses a stored procedure that returns the following data:
PRODUCT_ID TYPE YEAR STATUS
15242 01 1516 ACTIVE
54541 02 1617 ACTIVE
64454 01 1516 INACTIVE
73697 02 1516 INACTIVE
98878 03 1617 ACTIVE
I needed to get the counts per status, per year, per type, so I started building a matrix with STATUS as first column group and YEAR as its child, then, in the row group I only have TYPE. In the data fields I only have the count, so it looks like this:
ACTIVE INACTIVE
1516 1617 1516 1617
01 1 0 1 0
02 0 1 1 0
03 0 1 0 0
My problem is the following. I want add a DIFF column (example below) that calculates the difference between the two years, but the problem is that since all is done dynamically, I don’t know how to access the text boxes with the counts to calculate the difference. I could build a stored procedure that calculates all those numbers, but it would be a slower solution since the field TYPE will grow over time.
ACTIVE INACTIVE
1516 1617 DIFF 1516 1617 DIFF
01 1 0 1 1 0 1
02 0 1 1 1 0 1
03 0 1 1 0 0 0
Any help will be appreciated. Thank you guys in advance.
I don't think you'll be able to make a matrix work the way you want without using a bunch of LookUps that would kill performance.
I would make a regular table and filter the data in the expression to separate the years. You'll have to figure out some logic based on your data to determine which year is the current and which is the last year.
You would use the same grouping for the TYPE as you do now.
Assumeing you have identified the previous can current year:
=SUM(IIF(Fields!YEAR.Value = Parameter!Current_Year.Value, 1, 0)
For the DIFF column, use
=SUM(IIF(Fields!YEAR.Value = Parameter!Current_Year.Value, 1, 0) - SUM(IIF(Fields!YEAR.Value = Parameter!Previous_Year.Value, 1, 0)
You could use a variable or a Field in your query to identify the current year - it doesn't need to be a parameter.
You could still use the matrix for your Statuses (Stati?) for the Active and Inactive.
I have found a way to calculate differences between matrix columns (available from SSRS 2008 and up) using the previous function. Look at my answer to this question. how to subtract adjacent columns in an ssrs matrix
how to subtract adjacent columns in an ssrs matrix

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.

SSRS Stacked Column Chart - Multiple column overlap

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 ...