Data visualisation is an art and a science and its primary goal is to communicate information clearly and efficiently via statistical graphics, plots and information graphics. Sometimes, we really want a checkboxes or radio buttons displayed on a report to full-fill the client requirements .
In our last discussion, we have already learnt that how to add checkboxes on the report. We will continue with the previous report and will learn how to add radio buttons in a column on our SSRS report.
For the better understanding, we will take an example of week days where current week day should be checked in and other days should be unchecked in our report. We are going to generate dummy data by helping of Common table expression feature of SQL as given below:
------ Create on the fly CTE Table
;with CurrentDay as
----- set weekday conditions
------ Pull Data From CTE Table: CurrentDay
----- set weekday conditions as 0 and 1
order by WeekDay;
Now, we have the data table and we want to display this data on the SSRS report where current day =1 should be checked in the radio button and current day=0 should be unchecked in the radio button as given below:
There are very simple instructions to create this kind of report in SSRS as given below:
In the SQL Server Data Tools environment, right click on the last column of the report and add column in left as given below:
After adding the new column to the report, just put the current day value in the column and change the column header as Current Day – Radio Button and Preview the report as given below:
Now we have the report having current day values as 1 and 0. Now, we want to change these values with radio buttons and do the following setting against Current Day detail column-
Change font to Wingdings 2 and font size =16
Right click on the Current Day – Radio Button and click on Expression as given below:
In Expression window, we should write the following condition as given below:
= IIF(Fields!CurrentDay.Value=1,Chr(158), Chr(153))
Chr(158), for a filled-in Radio Button
Chr(153), for a empty Radio Button
After putting the conditional settings for radio buttons, click OK button and preview the report as given below:
We can do the same setting for background color for the checked and unchecked rows as given below:
We can generate checkboxes, radio buttons in the report by doing some additional expression settings on the textboxes and change font type and font family also. To generate checkboxes and radio buttons conditional data should be Boolean to write down the simple conditional expression to avoid the complex conditional expressions.