WordCloud custom visual in Power BI gives a great way to visualize the most occurring words in the data. The size of the word depends on how frequently it appeared in the data-set. One can limit the number of words to be displayed in WordCloud. The defualt setting displays 200 words in this visual.
But, have we ever thought of modifying this word limit without changing the underlying word-limit setting in the visual. Basically creating a slicer in the report and then changing the number of words to be displayed in the WordCloud.
This article here gives a workaround on how one can achieve this functionality in Power BI.
Let us consider a sample data where we have got words from the plays written by famous Shakespeare.
Not going much in detail in the data, we will take Column5 as the main column which has got list of words to be visualized in the WordCloud and ignore the other columns.
I simply drag Column5 on a WordCloud visual in Power BI and get the following:
The default setting for this visual is to show the Maximum number of words as 200; as shown below:
I will modify this limit to just show me 150 words.
Now we need a slicer on this page, so that I can modify the number of words by making a selection in the slicer, rather than changing the word-limit at the visual level settings.
Let us do some transformations in the Power BI Query Editor to achieve this.
In Power BI Query Editor, go to the data-set and right click on it to Reference option as shown below:
This will just create a reference to the original dataset as shown below:
I have just renamed it to "Shakespeare Plays Words Unique". You can rename it at your ease.
Now let us remove the other columns and just keep Column5 in this new referenced table.
Now let us remove duplicate values from this column and keep only the distinct words:
The next step would be to give these words a unique identifier. For this we will use ADD COLUMN and then an Index column:
Once we create an index column, we get the following data:
Now Close & Apply the above changes and go to Model section where we can see our data model:
We see both our tables here and we create a relationship between them on Column5 column:
Now we have created here is a One to Many relationship from the referenced table to the main table:
Looking at the above relationship, the columns from the new referenced table can filter our original table.
Next step is quite simple. We move the INDEX column in a slicer as shown below and renme it to Select No. of Words for Wordcloud:
As I have by default limited 150 words in the WordCloud visual, I go to this slicer and put a visual level filter to show me values from 1 to 150 as follows:
Start changing the selection values in this slicer and you will see that the WordCloud visual changes and displays the number of words based on this slicer selection:
Voila! We see how seamlessly we can modify the number of words to be displayed in the WordCloud visual.