I am working on color code issues in a column. I am using a nested if statements. Both portions work by themselves but when tried with nested the portion working from the lookup doesn't work. Below is the my expression.
if
(
Lookup(Fields!Equipment_Key.Value,Fields!Equipment_Key.Value,Fields!EW_last_SM.Value, "SM_Info")>
Dateadd("d",+2, lookup(Fields!Equipment_Key.Value,Fields!Equipment_Key.Value,Fields!EICT_Last_SM.Value, "SM_Info")), "RED",
iif(Me.value = "NOW","YELLOW",
"WHITE")
)<<
The issue was multiple data types in the same column. Workaround was to ad 2 columns and put each part of the if statement in its own column then referenced the 2 columns for the color coding.
Related
I have a crosstab query which returns results based on consumer demand for a bunch of material numbers. The material numbers become my field names in the crosstab query, and later the values from those fields are displayed in a form.
In the form, I display the value in a textbox. There are a couple of these textboxes where I need to sum the total of two or more values from these fields. Not a big deal it's a simple expression. For example (in the Control Source property): =[H123457] + [H123456].
This works well UNTIL there is no demand for a particular material number. In this case, the field doesn't show up in the crosstab query and I'm left trying to sum two fields where one doesn't exist.
I've tried IIf(IsError([H123456]), 0, [H123456]), Null expressions, Nz function, etc but cannot figure out how to dynamically solve the #Name issue that ends up populating the text box.
Essentially what I want is for a 0 value for the field that doesn't exist, so I can add it to the value where the field DOES exist - is this possible?
Regards!
June7 provided the answer in the allenbrowne.com link. Essentially, you need to add all of the possible field names to the Column Headings property in the crosstab query property window. Then it's a simple matter of adding an Nz() function to handle null values.
Thanks June7!
I am comparing 2 similar tables from different data warehouses and writing a report to highlight the discrepancies based on the differences. I would like to highlight the column values of the 2 fields if they are different. So, I am trying to write the Fill COLOR Expression which can change the color based on the value in the column.
I have tried writing some expressions.
Below are the examples:
I tried :
=IIF(Fields!DB1.Value=”NULL”,”Red” ,”White”) Or
IIF(Fields!Db2.Value=”NULL”,”Red” ,”White”) Or IIF(Fields!DB1.Value=Fields!DB2.Value,"NO Color","Red")
--Not Working
=IIF(Fields!DB1_Number.Value<>Fields!DB2_Number.Value,"NO Color","Red")
-- Not Handling NULL
There are no error. It is just that the code is not behaving as per the intention.
Just use the second expression and check for Null before:
=IIF(IsNothing(Fields!DB1_Number.Value) And IsNothing(Fields!DB2_Number.Value), "Red",
IIF(Fields!DB1_Number.Value <> Fields!DB2_Number.Value,
"White",
"Red")
)
I would like to color a cell based on the header and row values, not the cell value. In the sample below, when [ship_prom] = [produced_month] the [sum(wgt_scaled)] cell should go green (marked by X in the example).
[produced_month]
[ship_prom] [Sum(wgt_scaled)]
201812 201901 201902
201901 2.1 X 3
201902 1.5 X
Sorry if formatting doesn't work - tried pasting in an image but that failed too..
I tried conditional formatting of [Sum(wgt_scaled)] using =iif(Fields!ship_prom.Value=Fields!produced_month.Value,"Green","No Color")
but not all cells have values, and every null value cell turned green.
Additional from DonD:
The actual report has several additional fields / groups, so your comment around it being in that area is appropriate. I tried to simplify the report to just the basic data but still am not getting the same output as you.
reduced report info
#steve-o169 Since you are able to produce the report using the Switch, I'll go ahead and mark your answer as best. Thanks for the help!
design layout example
sample desired output
Actual data query and subset of data
Looks like you just need to add another conditional statement to account for NULL values. But personally, I would suggest implementing a switch for better control. Try the following expression.
=Switch(Fields!ship_prom.Value=Fields!produced_month.Value AND TRIM(Fields!ship_prom.Value) <> "","Green",
true, "No Color")
EDIT: Might need to see the query before I can really figure out the problem at hand here. I'm unable to reproduce your issue. I've created a simple dataset with the following query.
CREATE TABLE #temp(ship_prom INT, produced_month INT, wgt_scaled DECIMAL(2,1))
INSERT INTO #temp (ship_prom, produced_month, wgt_scaled)
VALUES (201901, 201812, 2.1), (201902, 201812, 1.5), (201901, 201901, NULL),
(201902, 201901, NULL), (201901, 201902, 3.0), (201902, 201902, NULL)
SELECT * FROM #temp
I've laid out my table with a column group on produced_month and a row group on ship_prom and grouped by ship_prom with the following layout.
Using the exact switch expression from my answer, I was able to achieve the following result.
I'm New to SSRS.
Im trying to create a report where i need to group by [DATA Flag] column which is working fine ,but once the data is grouped i need to set the DATA FLAG ="TotalCancellations" and there is another column CancellDays which i need to set it as <120 .
I tried
Option 1:-
So to achieve this i have added TWO filters one with
Expression : DATA FLAG
Operator =
and Value as TotalCancellations
and the other filter as follows
Expression : Cancelldays
Operator =
and Value as < 120
But its not working and giving empty result,i have records with Cancelldays <120
Option 2 :-
Right click on Group and in General Tab ,Group on Expression as below ]
Fields!DFlag.Value = "TotalCancellations" AND Fields!DFlag.Value <120
which didnt work :(
this is similar to writing having clause in SQL i believe but im not getting how to implement that here in SSRS.
i can add in SQL Query but its already a huge query with lot of unions so please suggest me if there is any way i can implement here in SSRS
Im using Matrix in SSRS 2008
Adjusting the syntax for your option 1 is probably the easiest solution. In the Group Properties, under the Filters section, enter these two filters:
Expression: [DFlag] (Text)
Operator: =
Value = TotalCancellations
Expression: =Sum(Fields!CancelDays.Value) [enter this in the expression builder] (Integer)
Operator: <
Value: 120
Putting all the filters in a single expression, like your option 2, can be useful if you need to filter by one criteria OR another.
Below are the filer expressions
and this is how group by is
The filter should be implemented at the tablix level, not at the group level.
I am using a tablix in an rdlc report which uses a flat (Single row datasource), however the values which are displayed are in multiple rows.
I need to add alternate row coloring for the same,I cannot use a RowNumber as I am working off a flat dataset.
Are there any other approaches I can take ?
TIA
I'm not certain what you are referring to as a flat single row datasource appearing as multiple rows. I am assuming what you actually have is a regular table of values.
You can use a combination of CountDistinct and RunningValue to calculate a row number in the background that you can then use to set the BackgroundColor property of your rows.
For example the following expression in the BackgroundColor property of the tablix row
=iif((RunningValue(CountDistinct(Fields!Serial.Value), Sum, "DataSet1") mod 2) = 0, "Tomato", "LimeGreen")
Sets this table to have alternating red and green rows, without editing the datasource at all.
Change the Background color for the row to the following expression, changing the data set name and color choices.
=IIF(RowNumber("AdverseEventsDataSet") mod 2 = 0,"Silver","LightGrey")