March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello everyone,
I would like to negate all numbers in the column that contain the status 1 and 2.
Current:
Status | Number |
1 | 5 |
4 | 19 |
1 | 8 |
2 | 10 |
According to the formula:
Status | Number |
1 | -5 |
4 | 19 |
1 | -8 |
2 | -10 |
I already have this formula in M for the number 1, but it doesn't work. Where is my mistake in thinking?
= Table.ReplaceValue(#"ReplacedValue",each [Number], each if [Status]=1 then each [Number] * -1 else [Number],Replacer.ReplaceValue,{"Number"})
I thank you for your help.
Solved! Go to Solution.
Hi @azaterol
You have an extra keyword each before [Number] * -1
Try this instead:
= Table.ReplaceValue(#"ReplacedValue",each [Number], each if [Status]=1 then [Number] * -1 else [Number],Replacer.ReplaceValue,{"Number"})
Also, you could handle Status 1 and 2 in the same step if you want, for example:
= Table.ReplaceValue(#"ReplacedValue",each [Number], each if [Status]=1 or [Status] = 2 then [Number] * -1 else [Number],Replacer.ReplaceValue,{"Number"})
Regards
Hi @azaterol
You have an extra keyword each before [Number] * -1
Try this instead:
= Table.ReplaceValue(#"ReplacedValue",each [Number], each if [Status]=1 then [Number] * -1 else [Number],Replacer.ReplaceValue,{"Number"})
Also, you could handle Status 1 and 2 in the same step if you want, for example:
= Table.ReplaceValue(#"ReplacedValue",each [Number], each if [Status]=1 or [Status] = 2 then [Number] * -1 else [Number],Replacer.ReplaceValue,{"Number"})
Regards
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
16 | |
13 | |
13 | |
9 |
User | Count |
---|---|
36 | |
31 | |
20 | |
19 | |
17 |