I trying to colour code a group within a group based on a value.
enter image description here
I am quite new to SSRS, and have tried various expressions, SWITCH, IIF etc but I cant seem to get them to reference the various criteria and groups correctly.
You've not explained what your criteria is so this is just a guess. I'm also assuming that the Target values are numeric, so 5 and not 5 days for example.
I'm also assuming that you want the background to be green is the count of DAYS2 >= Target
If this is the case then you can do something simple like this
=IIF(COUNT(Fields!DAYS2.Value) < Fields!Target.Value, "Green", "Red")
Related
I have an issue with changing colour of a column through an expression. The column of which I want tot change the background colour of has a time value. The format is hh:mm, currently I am using this expression:
=IIF(Fields!FacturatieTijd.Value >= 5, "Red", "Lime")
With this expression it only changes the colour of the cells which dont have a value in it(Null). I have tried using "05:00" in my expression but that gives an error..
Regards.
It seems like you're going to want to get the hours separated from your time to compare correctly. To do that, you'll need to use the Datepart function within your IIF. Try the following expression.
=IIF(DatePart("h", Fields!FacturatieTijd.Value) >= 5, "Red", "Lime")
In theory, this should extract an integer value for the hour and compare it against 5, giving you the result you need. I haven't actually tested this, but it should work.
I have a question, want some assistance.
Q) My question is that i have a chart in which analyst assigned for many incidents and some analyst have 1 or two incident assigned. just because of this the bar chart looks ugly some time. So thats why i used a new chart to represent Min incident count. But i want there some creativeness, for which i want there a radio button or OnClick event ( I do not know how to use both these. When report runs by default it`ll show Max incidents count chart and when we used radio button it will show Min incidents count chart, on the same chart area no need of new area or on new page.
Kindly help me or refer me some links and with ideas. As i have searched many blogs but i didn`t get any big achievement.
Below is my Simplified query;
SELECT
Count(IncidentDimvw.Id)
,UserDimvw.FirstName AS Analyst
FROM
IncidentDimvw
FULL JOIN WorkItemDimvw
ON IncidentDimvw.EntityDimKey = WorkItemDimvw.EntityDimKey
JOIN WorkItemAssignedToUserFactvw
ON WorkItemDimvw.WorkItemDimKey = WorkItemAssignedToUserFactvw.WorkItemDimKey
JOIN UserDimvw
ON WorkItemAssignedToUserFactvw.WorkItemAssignedToUser_UserDimKey = UserDimvw.UserDimKey
WHERE
WorkItemAssignedToUserFactvw.DeletedDate IS NULL
GROUP BY
UserDimvw.FirstName
Having (Count(IncidentDimvw.Id) = (#Count))
Having Clause is right or wrong, i donot know.
I used the following expresion in series as you suggested.
=iif(Parameters!Count.Value, Max(Sum(Fields!ID.Value)), Min(Sum(Fields!ID.Value)))
Sample data is as folows;
Regards
Muhammad Ahsan
I can think of a couple of ways to approach this:
Dynamic expressions based on parameter
Say you have a simple DataSet like:
And also a boolean parameter called showMax.
We can create a simple bar graph based on this:
The most important thing to note is that Series value is expression-based:
In the above example the expression is:
=IIf(Parameters!showMax.Value
, Max(Fields!value.Value)
, Min(Fields!value.Value))
i.e. when showMax is true, report the Max values, otherwise report the min values.
In this case I've also updated the Axis title, Chart title, and Custom legend text to be expression-based:
Axis Title: =IIf(Parameters!showMax.Value, "Max", "Min")
Chart Title: =IIf(Parameters!showMax.Value, "Max per group", "Min per group")
Custom legend text: =IIf(Parameters!showMax.Value, "Max value", "Min value")
The chart behaviour changes based on what parameter is selected as required:
Set Visibility based on parameter
Another option is simply to have to charts and hide one depending on parameter selection.
For example, for the Max chart the Hidden property can be set to:
=Not(Parameters!showMax.Value)
Setting this property correctly for each report will mean only one is ever displayed to the user, i.e. it will look dynamic.
Either of these options should work; the first keeps the layout simple in the designer makes the chart more complex, the second makes the layout more complex but keeps the charts simple.
Hopefully one option will work for you.
Can anyone tell me how do I get the Max of a calculated field? Below is an image of my situation:
Note that Flag is of type int.
I want to write the expression in the image , but when I use it, it kinda does:
Sum(Sum(Fields!Flag.value))
Can anyone help me out on this. I think I need to add scope for the Sum(Flag) but when I add the group scope as EMPID as:
=iif(SUM(Fields!Flag.value,"Fields!EmpID.Value")>2,"RED",nothing)
It throws me an error saying something about the scope.
EDIT:
I need attendance of each employees. FLAG is basically 1 if absent and 0 if anything else.
The bottom row(Flag,Date,Status,Comment). Now I have an alert There:
=iif(Fields!Flag.Value=1,"RED",Nothing)
Beside the Textbox(Textbox62) in middle row(EmpID,EmpName) I did Expression:SUM(Flag) and in the Fill section in Text Box Properties i have done:
=iif(SUM(Fields!Flag.value,"Fields!EmpID.Value")>2,"RED",nothing)
So the above expression creates an alert if employee is absent more than 3 days.
The top most row(Department,Manager) can be drilled down for to see more detailed view of the report. Now my problem is, in the column (FLAG) i need to create a Background color change if any employee in a particular department is absent more than 3 days.so that we do not have to drill down all the departments in order see if any employee is absent or not.
So my approach was to see the Max(Sum(Flag))>2 then create color change. I tried:
=iif(MAX(Sum(Fields!Flag.Value))>2,"Red",Nothing)
It does not work at the Department level as it basically considers (SUM(Sum(Flag))).
Thanks................
If you don't specify the scope of an aggregate, it is assumed that you are using the current scope. For example, when you say
Sum(Fields!Flag.value)
It is interpreted as something like
Sum(Fields!Flag.value, "EmpID")
The scope is the name of the Group, not the name of a dataset field.
Depending on where it is in the table. When you want to say something like
Sum(Sum(Fields!Flag.value))
You need to specify the scope for each one that isn't going to be the current default.
In your case you should use something like this:
=iif(MAX(SUM(Fields!Flag.value, "EmpID"), "Department")>2,"RED",nothing)
Again, pay attention to which group each aggregate is referring to and where the expression is on the table.
Also, this expression in a textbox will just make the word "RED" appear in the box. If you want it to change the color, you have to put it in the "Fill color" expression in the properties.
I'm am having some trouble with conditional formatting in SSRS. I have tried Switch & IIF Statements (below). The report runs but is not returning colors as it I'm hoping it would. I'm trying to highlight dates which are <= today in red, and everything else will be black. Does it matter if this field is a date field? I've seeen other questions on here with the same issues but no resolutions. Was hoping today would be my lucky day to find an answer. Here is what I have tried and thank you in advance for any input.
=Switch( Fields!Decision_Must_Be_Made.Value <= today(), "Red",
Fields!Decision_Must_Be_Made.Value > today(), "Black")
=IIF( Fields!Decision_Must_Be_Made.Value <=today(), "Red", "Black")
Yes, it definitely matters if the field is a Date Time field. If it's a string, then you need to convert it to datetime first. How you do that will depend on the format of the string. But it will be much better if you can stick with a datetime field from the database. (I've seen where some will format a date to a string in the select of the sql query. Don't do that. Format as late as possible: in SSRS, at the text box level.)
If it is a dateTime, break up your formula to find out what's not working as expected and make it more visible, if only for debugging. Put this in the expression of a cell, for example:
=IIF( Fields!Decision_Must_Be_Made.Value <=today(), "Old", "New")
Edited to add information on where the color formula should be added:
Sounds like you don't have the IIF specifying the color in the right place. There are a few different places you could specify this: it needs to be in the properties of either the textbox or the placeholder. The value for these things should simply be your date field (=Fields.Decision_Must_Be_Made.Value) but the font color needs to be specified separately. One place to do this is in the Text Box Properties dialog. In the font pane, you need to specify the font color. The Fx symbol indicates that you can specify a formula. Click this button for a place to enter your '=iif...' formula.
Admittedly this does not answer your scenario but may help someone else. I had an issue where a stand-alone textbox using a scenario where I wanted to display an error message when there was either no record or duplicate records. My formula "=IIf(IsNothing(First(Fields!MyField.Value)) Or First(Fields!MyField.Value) <> Last(Fields!MyField.Value), "Red", "SomeOtherColorButNotBlack") which did not render the correct fore-color (came out "Black") however, doing a similar expression that equates to True or False on a Tablix or Matrix does work fine. Another one for MS to solve. I found my own workaround by setting the color to always be red and then the expression of the Text to be blank when no error.
I have SSRS solution for SQL 2005 and 2008.
I am showing output in the form of chart- column chart with each column representing different database.
Is there a way to display each column in different color?
Regards
Manjot
You can use a formula to set the colour of each column, but that would work best if you knew what the individual series values ('databases'?) were going to be.
Right-click on your chart and bring up its properties. Now switch to the Data tab and select the first item in the Values list. Click the Edit... button to show the properties for the values (the columns) in your chart. Over on the Appearance tab there's a Series Style... button which takes you to another dialog.
On this new Style Properties dialog, switch to the Fill tab. That's where you set the colour for each of your columns. This can be a formula, so you might make it something like:
=Switch(
Fields!Database.Value = "master", "Blue",
Fields!Database.Value = "msdb", "Red",
"Green")
If you don't know in advance which 'databases' are going to be represented on the chart, this method won't work very well. In that case you might be able to come up with a formula which hashes the database name and comes up with a colour to match. That sounds like an interesting challenge, so add to your question if you need help doing something like that.
Edit
I just got a hash-based-colour-scheme working. It's a pretty nasty piece of code, but it did manage to get me a unique colour for every (string valued) column. Perhaps someone can come up with a better algorithm and post it here. Here's mine:
="#" & left(Hex(Fields!Database.GetHashCode()), 6)
So that's getting the HashCode for the string (a numeric value) and converting it to hex, then taking the leftmost six characters and prepending it with a "#" sign. That gives us a string that looks like a colour value (eg #AB12F0).