|
Report with a custom SQL query |
|
|
You will create a summary of how often roles occur in user groups – in total and broken down into activated and deleted accounts. The report has two multiple-selection parameters: group and role. 1.Select the report type and the data source: •In the report designer, select Tabular report. •Go to the data source settings. •Select Custom SQL query. 2.Insert the SQL query in the editor:
3.Select the report fields: displayed, grouping and summary fields. 4.Fill in the report title, save the changes and check the report preview. 5.Prepare data for the selection lists in the parameters: in the side pane, add a dataset with the user_groups and user_helpdesk_roles tables. 6.Add two report parameters – group and role – with the options: multiple selection, no null value, no default value. 7.Add conditions to the basic SQL query (after the last JOIN expression):
In the conditions: •@role_ids and @group_ids are the values of the query parameters •An empty parameter means that all values are selected •The string_to_array function splits the values into a list of numbers •The any() function checks for a match with the list 8.In the Data Source Wizard window, create the query parameters: •role_ids – type Expression; result: text created by joining the values of the RoleId report parameter (join function) •group_ids – in the same way 9.Adjust the appearance: change the column names, colors and fonts. 10.Correct the summary fields: remove unnecessary values and change the format to a readable one. Check the result. 11.Add rows for the parameter values: right-click on a table cell and add rows from the context menu. 12.Enter the parameter names and align the font formatting. 13.Display the parameter values: click on the function icon and, in the editor, add the expression Iif(Any(?RoleId) == False, GetLocalizedString('All'), GetDisplayText(?RoleId)). Add an expression for the second parameter in the same way. 14.Check the result. Back to Report creation in the designer. |