Forum Discussion
ryan_b_123
2 years agoFrequent Visitor
Using value from column to affect calculation in Power Query
Col 1 Col 2 Col 3 Desired Result 4 + 5 9 3 - 2 1 Let's say I have above dataset: To do above, I could write a formula in Power QUery something like "if [col 2] = "+" then [C...
- 2 years ago
Yes, there is a way.
Use Expression.Evaluate
You can build a string from the first 3 columns ( either by appending with & or use Text.Combine and then just pass that to Expression.Evaluate()
ryan_b_123
2 years agoFrequent Visitor
Thank you, so much. This is exactly what I am looking for. I am curious about one thing though.
Expression.Evaluate(Text.Combine({"5","=","5"}, " ")) will return true. Which is good.
Expression.Evaluate(Text.Combine({"hello","=","hello"}, " ")) will return an error. "The name 'hello' doesn't exist in the current context."
Do you know why we cannot use "=" operator for alphabetical comparisons?