Forum Discussion
LT4RFF
Helper I
1 year agoVery quick 'IF function' question
Hello, I have a column with multiple accounts. On each of those accounts I am responsible for a percentage. I would like to create a separate column and have a formula 'IF account = B1234 th...
- 1 year ago
If you only have a few accounts to add the percentage, the the formula provided by PwerQueryKees should be sufficient.
If you have a large number of accounts to consider, you would be better off creating a table of accounts vs reponsible percentages which you could then refer to for your Custom column.
Paste the below code into the Advanced Editor to see how that would work. In your real data, you would create the Responsible and Data tables separately.
let //sample table of responsibility #"Responsible Percent" = Table.Buffer(Table.FromRecords({ [Account="B1234", Percent=0.25], [Account="B5678", Percent=0.50]}, type table[Account=text, Percent=Percentage.Type])), //sample data table Source = Table.FromRecords({ [Account="B1234"], [Account="B5678"], [Account="A9876"], [Account="A1579"], [Account="C1234"] },type table[Account=text]), //Add responsible percent column per account #"Added Custom" = Table.AddColumn(Source, "Responsible Percentage", each try Table.SelectRows(#"Responsible Percent",(r)=> r[Account]=[Account])[Percent]{0} otherwise 0, Percentage.Type) in #"Added Custom"Responsible Table
Results
PwerQueryKees
Super User
1 year agoNo swith in Power Query.
so you formula would use in the add column dialog would be:
= if account = "B1234" then 0.25 else if account = "B5678" then 0.50 else 0
Oluwapelumi
Advocate II
1 year agoOhh...I thought the formula was to be used in Excel.