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.
ChandeepChhabra
Impactful Individual
7 years agoTHEG72 You can use DAX or M
Please refer to the Excel file for both solutions
Two quick things
- The label "cost" is written in 2 different ways, I have provided for that in DAX and M
- Please note that power query is case sensitive and DAX is not
Thanks
THEG72
Helper V
7 years ago- ChandeepChhabra7 years ago
Impactful Individual
- THEG727 years ago
Helper V
ChandeepChhabra Can you switch statement handle a zero value too ?
- ChandeepChhabra7 years ago
Impactful Individual
THEG72 No it can't for now. What label do you want in-case it is a zero?