The Image Link Formatter option in Column Formatting embeds an image within the report by processing the column value, that is a URL link, into an image displayed in HTML image tags within the report listing.
To embed an image in a report listing, follow the steps below:
Pre-requisite: The column value that will be displayed as an image must have URL links as column values stored in the database.
- Login as an authorized user.
- Click on the Plus sign that appears at the top right corner and select Report.
- On the New Report window, click on a metric view that will form the basis of your analysis. Here, for instance, the Site Performance view is selected.
- On the report interface, add your required data fields.
- To drag a data field in the Columns box, expand one of the folders that appear in the left pane of the report interface window and by using the click-and-drag method on the columns, populate the Columns box. You can use the search box, presented above the folders, to search for a specific column. Here, for instance, Current Count of Sites Activated (aggregate function), Study ID, Site Region, and Site Country are selected.
- Open the field menu on the column Site Country which will showcase the images and then select Format and then Edit.
- In the Column Formatting window, in the Format box select Image Link Formatter.
- Enter a URL in the Default Image box that will fetch an image if the column values in the database do not contain the desired image-specific URLs.
- You can specify the image width and height as a numeric value in the Image Width and Image Height box respectively. The numeric should be a value in pixels.
- Click the Cross icon to save the changes.
- As seen above, we are not able to see the images in the Site Country column as there may not be a column that can be fetched from the table that contains image links as values. To obtain images that correspond to the site region column, we can set up a calculated field that will help us retrieve the images.
- Click the plus icon that appears at the bottom left corner as shown above.
- In the Calculated Field window, provide the following inputs:
- Calculated Field Name: Specify a unique name for the calculated field. This will be used across all reports and dashboards. Here, for instance, the calculated field name is Site Region Image.
- Formula Type: Here, the type is chosen as Simple.
- Resulting Field Type: Here, the value Auto Detect is chosen.
- Build a Case - When - Then statement to specify values that will be fetched from a specific column and insert the corresponding image links (jpeg links) in the Then clause. Here, for instance, the column values are picked up from the Site Region column and if that holds true then corresponding image links (jpeg links) are inserted in the Then clause. Repeat for all the column values in the Site Region column.
- Click End to close the Case-When-Then statement syntax.
- Click Validate to validate the SQL query statement.
- Click Save to save the calculated field.
- From the left pane, select the calculated field and drag it across to appear in the Columns box and you can insert it next to the Site Region column or in the order you wish to see it in.
- Open the field menu of the Site Region Image column and select Format and then select Edit.
- Select Image Link Formatter in the Format box. Specify the width and the height of the image in the Image Width and Image Height box respectively.
- The resultant table is shown below. The report list is filtered on a specific study name and you can see the images in the derived column (calculated field) that match the site region column values.
|Note: For any new value in the column that cannot be matched to any image link in the SQL query statement, the calculated field (here, Site Region Name) will fetch the image from the jpeg image link inserted in the Default Image box seen in the column properties, as shown below.|