Forum Discussion
efilipe
9 years agoHelper IV
Transform to negative numbers
Hi all! I have, on my Excel file, earnings and expenses. Both are positive numbers. I want to import both information to Power BI, but I want to transform expenses only, to negative numbers, ...
- 9 years ago
If you expenses are in their own column, just choose Standard | Multiply from the Number Column area of the Transform ribbon and enter -1. Here is the M code:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtY31zcyMDRX0lEyNVCK1QGJWMBEDA2AQrEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}}), #"Multiplied Column" = Table.TransformColumns(#"Changed Type", {{"Value", each _ * -1, type number}}) in #"Multiplied Column" - 9 years ago
You can add a conditional column and then delete the original one.
let Source = Excel.Workbook(File.Contents("C:\ Transform to negative numbers.xlsx"), null, true), Table1_Table = Source{[Item="Table1",Kind="Table"]}[Data], #"Changed Type" = Table.TransformColumnTypes(Table1_Table,{{"data", type date}, {"tipo", type text}, {"destino", type text}, {"meio", type text}, {"conta", type text}, {"valor", Int64.Type}}), #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "valor_updated", each if [tipo] = "Saída" then -[valor] else [valor] ), #"Changed Type1" = Table.TransformColumnTypes(#"Added Conditional Column",{{"valor_updated", Int64.Type}}), #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"valor"}), #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"valor_updated", "valor"}}) in #"Renamed Columns"Best Regards,
Herbert
Anonymous
6 years agoNot applicable
Write a negative in your formula for a new column
For example
create a new column
in the formula bar write:
negative expenses = - expenses