1. Load your data:
Open Power BI Desktop and load your dataset.
2. Open Power Query Editor:
Go to the "Home" tab and click on "Transform Data" to open the Power Query Editor.
3. Add a Conditional Column:
In the Power Query Editor, go to the "Add Column" tab.
Click on "Conditional Column".
4. Define the conditions:
In the "Add Conditional Column" dialog box, provide a name for your new column.
Set the conditions for your column. For example, if you want to apply different formatting based on Gender and Maritial Status you can set conditions like:
If [Gender] is male, then "Mr"
If [Maritial Status] is Single, then "Miss"
Else "Mrs"
5. Add more conditions if needed:
Click on "Add Clause" to add more conditions as required.
6. Apply the changes:
Click "OK" to create the new conditional column.
7. Close and Apply:
Once you're satisfied with the changes, click "Close & Apply" to return to the main Power BI window with the updated data.
Apply conditional column to following data as follows
1. If gender is male and marital status is single than Salutation will be "Mr"
2. If gender is male and marital status is married than Salutation will be "Mr"
3. If gender is female and marital status is single than Salutation will be "Miss"
4. If gender is female and marital status is married than Salutation will be "Mrs"
Our dataset contains two columns, First column contains "Gender" and second column contains "Marital Status"
Define the conditions as follows:
In the "Add Conditional Column" dialog box, provide a name for your new column (Salutation).
If - Column Name = "Gender" - Operator = "Equals" - Value = "M" - Then, Output = "Mr."
Else If
If - Column Name = "Marital Status" - Operator = "Equals" - Value = "S" - Then, Output = "Miss."
Else
Else = "Mrs."