Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi all,
I have a column with both negative and positive values and I need to have them changed to the opposite. The positives are actually negative and negatives are positive. I know I can change them all to absolute, but can't think how to also store the positives as negative?
Hope this makes sense, no idea why the values are stored like this in the database.
Thank you!
Solved! Go to Solution.
You can simply multiply them with -1.
Isn't it?
I don't like creating a new custom column to multiply the old value by -1, so I solved the problem by transforming the value in place using a trivial custom function "Negate"
let Negate = ( x ) => try -1 * x otherwise null, Source = Table.FromRecords({ [CustomerID = 1, Name = "Bob", Value = 305 ], [CustomerID = 2, Name = "Jim", Value = -100 ], [CustomerID = 3, Name = "Paul", Value = 0.305 ], [CustomerID = 4, Name = "Pau2", Value = "0.305" ], [CustomerID = 5, Name = "Pau3", Value = null ] }), Negated = Table.TransformColumns(Source, {{"Value", Negate}}) in Negated
You can simply multiply them with -1.
Isn't it?
You're right! Didn't realise it's so simple.
Thanks a lot! 🙂
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
85 | |
77 | |
65 | |
52 | |
30 |
User | Count |
---|---|
115 | |
114 | |
71 | |
66 | |
39 |