Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi Team,
How to create a condition on text field
I got a field "Harm" and the values are :
Harm
A
B
C
D
i am trying to create a condition like
if (Harm =A then "nom",Harm =B,"pol" else Harm)
what is the best way to do this in Power query please?
Thanks,
Kumar
Solved! Go to Solution.
If you are trying to replace the values in the original column you can add the following code to your query...
Table.ReplaceValue(previousTableStep,each [Harm],each if [Harm] = "A" then "nom" else if [Harm] = "B" then "pol" else [Harm],Replacer.ReplaceText,{"Harm"})
If you want a new column then use the 'Conditional Column' button on the 'Add Column' ribbon.
Proud to be a Super User! | |
It is true, just put the column name inside [] like
if [Harm]="" ,,,,,,,,
so go to the transform tab and pick add new column and start to write your formula in the bellow syntax
if ......... then ................ else ........................
If you are trying to replace the values in the original column you can add the following code to your query...
Table.ReplaceValue(previousTableStep,each [Harm],each if [Harm] = "A" then "nom" else if [Harm] = "B" then "pol" else [Harm],Replacer.ReplaceText,{"Harm"})
If you want a new column then use the 'Conditional Column' button on the 'Add Column' ribbon.
Proud to be a Super User! | |
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 6 |