This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hello! How can I convert a column by a condition?
Something like this
if type = №2 and type2 = true then List.Product({_, -1}) else List.Product({_, 1})
???
Solved! Go to Solution.
Hi @mechanix85,
You could try this. It worked in my test.
#"Replaced Value" =
Table.ReplaceValue(#"Changed Type1",
each [value],
each if [type] = "No2" and [type2] = true then [value] * -1 else [value] * 1,
Replacer.ReplaceValue,{"value"}),
Best Regards!
Dale
Dale! The Table.ReplaceValue solution works great! I was able to add a custom function to this solution so I can reference other columns like this:
=Table.ReplaceValue(
table,
each [ColumnToModify],
each fx_CustomFunction( [ColumnAsArgument1], [ColumnAsArgument2] ),
Replacer.ReplaceValue,
{"ColumnToModify"}
)
Question for the thread:
Does anyone know if there is a way to have Table.TransformColumns use other columns in the table as arguments to the transformation fuction? (like this...)
Table.TransformColumns(
table as table,
{{column_name, fx_CustomFunction ( [ColumnAsArgument1], [ColumnAsArgument2] ), DataType}}
)
Thanks for any insight on this!
Hi,
Dale's solution does work for me. However I was wondering if there is a way to transform multiple columns in one step? Right now I have to repeat on every column I wish to transform.
Thanks.
Carl
Hi @mechanix85,
You could try this formula.
= if [type] = "No2" and [type2] = true then [value] * -1 else [value] * 1
Notes: M is case sensitive.
Best Regards!
Dale
@v-jiascu-msft, Yes, i can do this, but I do not want to add new column... Table.TransformColumns can do it without new column, but I can not understand how to add a condition
Hi @mechanix85,
You could try this. It worked in my test.
#"Replaced Value" =
Table.ReplaceValue(#"Changed Type1",
each [value],
each if [type] = "No2" and [type2] = true then [value] * -1 else [value] * 1,
Replacer.ReplaceValue,{"value"}),
Best Regards!
Dale
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 31 | |
| 26 | |
| 23 | |
| 22 | |
| 13 |
| User | Count |
|---|---|
| 61 | |
| 47 | |
| 27 | |
| 23 | |
| 18 |