2020/03/17

Power BI - Rendering Rich Text in Table Viz


Power BI Table Viz does not support formatting the content stored in Rich Text format in the database columns.  The data will be displayed as it is in the Power BI Table Viz.

For Example:
Data stored in the table 

When Imported into Power BI and displayed in the Table viz, the html formatting tags are retained and displayed as it is :


The above way of presenting data poses difficulty to read the content amidst of all the tags.

Power Query M language has a built-in function "Html.Table" which can be used to format the code as per the html tags specified int he contents.

In order to remove the tags and format code as per the specified tags, follow these steps.

#1 Import the table into Power BI as usual, and edit the table using Query Editor.
Original Columns in the table with rich text format:


#2        Add a new column to format the contents of "TimelineDescription" 



 #3 Use below formula for formatting the contents.




if [TimelineDescription] <> null
then Html.Table(
[TimelineDescription], {{"text",":root"}}
)
else null

This will produce HTML table, expand column properties and extract "text"  as below-

                            

#4  This will replace the HTML table with formatted text as below:


In this 1 - is original column and 2 - is the formatted text.

#5 In the Power BI Table viz the formatted is displayed as below:






No comments:

Post a Comment

File Handling with Python

This little utility is for copying files from source to target directories.  On the way it checks whether a directory exists in the target, ...