Change color to a field when another field is the same
I have a report that uses a field called PO Number. What happends is via data entry error a PO number could end up on a report twice, 1 correct and 1 incorrect, and what i want to do is if a PO number is on a report twice to highlight it red. example po number 123456 and 123456(should be123457) is on a report twice to color the text red. any help on this is great appreciated. Thanks
October 28th, 2010 4:12pm

If these are on the same row in different fields use an =ii(Fields!OtherField.value=Fields!ThisField.value,"Red","White) type expression if expression in SSRS to set the cell colour. If you are trying to evaluate across rows you will need to rewrite the query with a sub select. my blog http://karlberan.wordpress.com/
Free Windows Admin Tool Kit Click here and download it now
October 28th, 2010 4:28pm

They are the same field but different row. heres a better example this is how they would look in a report same column but different row this set of data is all in a detail row within the report 123456 - turn red 987455 654123 471412 123454 123456 - turn red
October 28th, 2010 4:38pm

Unless the PO numbers are sorted I don't think there is any way to do this in RS - your best bet would be to return a count of each PO number as part of your query and then apply an expression to the background colour as such =iif(Fields!POCount.Value > 1, "Red","White")Rgds Geoff
Free Windows Admin Tool Kit Click here and download it now
October 28th, 2010 7:40pm

how would i do a count for each specific PO?
October 29th, 2010 7:51am

DECLARE @T TABLE ( PO INT ) INSERT INTO @T SELECT 123456 UNION ALL SELECT 987455 UNION ALL SELECT 654123 UNION ALL SELECT 471412 UNION ALL SELECT 123454 UNION ALL SELECT 123456 ---demo SELECT C.PO, CASE CNT WHEN 1 THEN 'Black' ELSE 'Red' END As Color FROM (SELECT PO , COUNT(*) AS CNT FROM @T GROUP BY PO ) AS C INNER JOIN @T T ON T.PO = C.PO Dave Frommer - BI Architect Slalom Consulting (www.slalom.com)
Free Windows Admin Tool Kit Click here and download it now
October 29th, 2010 9:07am

Is there an easier way to do this? My guess is that my request is not an easy one, and there is not an easy way to do ti....
October 29th, 2010 9:27am

Order By PO Number in your query and use a ROW_NUMBER OVER (PARTITION BY PO_Number Order By PO_Number asc) as Row_No then test for Row_No > 1 in an expression to set the background colourRgds Geoff
Free Windows Admin Tool Kit Click here and download it now
October 30th, 2010 5:49am

Write a stored function that returns the # of times a po# occurs. In the query call the function such as select PO#, GetCnt(PO#) from x On each row you now have the # times that PO# occurs. In the report use the IIF statement to test the po count value. =iif(Fields!POCount.Value > 1, "Red","White")
October 30th, 2010 6:35am

Order By PO Number in your query and use a ROW_NUMBER OVER (PARTITION BY PO_Number Order By PO_Number asc) as Row_No to return an incrementing number which restarts at each PO Number then test for Row_No > 1 in an expression to set the background colour - if there is only one PO Number then Row_No = 1. If there are 2, the 1st onewill have Row_No = 1 the 2nd will have row_no = 2 etc etc Testing for Row_No > 1 wil ltherefore pick up all your dupes Rgds Geoff
Free Windows Admin Tool Kit Click here and download it now
October 30th, 2010 12:46pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics