Search code examples
sql-serverreporting-servicesssrs-2016

Highlight top and bottom 10% in SSRS table


I want to highlight the Top and Bottom 10% of values in my SSRS Table.

The sample table should look like this - I have prepared below in Excel Sheet,

enter image description here

Is it possible in SSRS-2016?


Solution

  • Can be achieve using below SQL query and SSRS expression.

    ;WITH cte AS (
    SELECT TOP (10) PERCENT MARKS,EmpName, 1 Ten FROM TableName ORDER BY MARKS
    UNION ALL
    SELECT TOP (10) PERCENT MARKS,EmpName, 2 Ten FROM TableName ORDER BY MARKS DESC
    )
    
    SELECT m.EmpName,
           m.Marks,
           CASE 
                WHEN cte.Ten = 1 THEN 'Green'
                WHEN cte.Ten = 2 THEN 'Red'
                ELSE ''
           END RedGreen
    FROM   TableName m
           LEFT JOIN cte
                ON  cte.Marks = m.Marks 
    

    Once dataSet is ready, we just need to set expression for Fill Color,

    enter image description here

    Let me know if you need more help.