Search code examples
visual-studio-2008reporting-servicesssrs-tablix

SSRS: Getting a specific value from different rows of a dataset


I'm sitting here, working with SQL Server Reporting Services and I am stuck with the following problem:

I have written an SQL Statement which returns for a Client for every day of the year if he was absent or not.

So for example the result could look like this:

-------------------
| Date   | Absent |
-------------------
| 01.01. | True   |
| 02.01. | False  |
|    .   |   .    |
|    .   |   .    |
| 31.12. | False  |
-------------------

Now for the Report I want to use a Tablix where I have the days as column headers and the months as row headers and in the right cell a value which marks if the client was on a day absent or not (as an example I use :) as here and :( as absent):

-------------------------------
|    | 01 | 02 | .  | .  | 31 |
|Jan | :( | :) | .  | .  | :) |
|Feb | .  | .  | .  | .  | .  |
| .  | .  | .  | .  | .  | .  |
| .  | .  | .  | .  | .  | .  |
|Dec | .  | .  | .  | .  | :( |
-------------------------------

I just can't come up with any solution for my problem so any help will be appreciated :)


Solution

  • Create a Tablix, with the columns grouped on the expression =Day(Fields!Date.Value) and the rows grouped on =Month(Fields!Date.Value)

    For the cell value set the source to an expression:

    =IIF(SUM(Fields!Absent.Value)>0, ":(" , ":)" )
    

    Of course, you could add an image, and change the image source dynamically with a similar expression.