Data Visualization Tips (Power BI): Convert categorical variables to dummy variables
Description:
Apart from doing data visualization, like plotting charts and showing KPIs, Power BI can also perform some computational functions. However, you may find that there are categorical variables in your dataset. This may create an obstacle to use Power BI. In this article, you can learn a very easy way to convert categorical variables to dummy variables.
Input file:
Demonstration:
First, after you load the data into Power BI, go to "Edit Queries".
Then, choose the categorical column (column "FTR" is chosen for demonstration), and click "Pivot Column".
And select the appropriate values column.
* Power BI does not allow you to choose the same column, i.e. "FTR" column as the values column, but this can be changed manually later.
After that, you will see the dummy columns appearing at the rightmost end.
However, when you check the whole dataset again, you will find that the column "Div", which is the values column used in the Pivot column setting, disappears.
If you want to keep this column or simply use "FTR" as the values column, go to "Advanced Editor".
Change "Div" to "FTR". This is changing the values column of the Pivot Column's setting to "FTR",
Finally, you successfully convert the categorical variable to dummy variables.
Comments
Post a Comment