Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.
Hello. I want to make a minus sign in front of a value in a column that corresponds to a text value in another column. Shown under I want make a "-" sign in front of all the numbers in lots when buy or sell is sell?
Like this:
Buy | 2 |
Sell | -1 |
Sell | -3 |
Buy | 2 |
Sell | -1 |
Solved! Go to Solution.
Hi @LFM, add as custom column:
if Text.Lower([Buy or Sell]) = "sell" then [Lots] * -1 else [Lots]
Whole code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnb18VHSUTJUitWJVnIKjQSyjcBsqIQpMscYSZUJEtsQWRFQeywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Buy or Sell" = _t, Lots = _t]),
ChangedType = Table.TransformColumnTypes(Source,{{"Lots", type number}}),
#"Ad_Lots +/-" = Table.AddColumn(ChangedType, "Lots +/-", each if Text.Lower([Buy or Sell]) = "sell" then [Lots] * -1 else [Lots], type number)
in
#"Ad_Lots +/-"
Hi @LFM, add as custom column:
if Text.Lower([Buy or Sell]) = "sell" then [Lots] * -1 else [Lots]
Whole code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnb18VHSUTJUitWJVnIKjQSyjcBsqIQpMscYSZUJEtsQWRFQeywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Buy or Sell" = _t, Lots = _t]),
ChangedType = Table.TransformColumnTypes(Source,{{"Lots", type number}}),
#"Ad_Lots +/-" = Table.AddColumn(ChangedType, "Lots +/-", each if Text.Lower([Buy or Sell]) = "sell" then [Lots] * -1 else [Lots], type number)
in
#"Ad_Lots +/-"
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.