Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. 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 +/-"
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 6 | |
| 6 | |
| 5 |