Forum Discussion
THEG72
Helper V
7 years agoCalculated Column with numeric field and text field
I have the following table data and would like to make a custom column that will have 2 possible outputs "Cash Inflow" or "Cash Outflow" as shown in the formula required section below. There are...
- 7 years ago
- 7 years ago
Hi,
This M code works
let Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"Finance Group", type text}, {"Value", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Finance Group]="Revenue" then if [Value]>0 then "Cash Inflow" else "Cash Outflow" else if [Value]<0 then "Cash Outflow" else "Cash Inflow") in #"Added Custom"Hope this helps.
Ashish_Mathur
Super User
7 years agoHi,
This M code works
let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Finance Group", type text}, {"Value", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Finance Group]="Revenue" then if [Value]>0 then "Cash Inflow" else "Cash Outflow" else if [Value]<0 then "Cash Outflow" else "Cash Inflow")
in
#"Added Custom"
Hope this helps.
THEG72
Helper V
7 years agoAshish_Mathur thanks for your M code, what happens if the value is zero? how would you code account for that?
- Ashish_Mathur7 years ago
Super User
What would you want the result to be?