Forum Discussion
Anonymous
10 years agoNot applicable
Using the "IF" function to create a new column
Hello, I need to create a new column and it must use the condition "IF", for example: = If (Provider = '05521463000112 - CAMARA MUNICIPAL TERESINA', 'Transfer to Camara' if (Provider = '4125...
Anonymous
10 years agoNot applicable
Thus could apply only if I use a value of a given field, as I do in the event of two conditions as the example that I spent?
Greg_Deckler
10 years agoCommunity Champion
Anonymous - Here is an example of a lookup function that uses a database table as a source of its information:
let fnHex2DecFromDB = (input) =>
let
Source = Sql.Database("MySQLServer", "MyDatabase"),
dbo_Hex2Dec = Source{[Schema="dbo",Item="Hex2Dec"]}[Data],
Record = Table.First(Table.SelectRows(dbo_Hex2Dec, each [Hex] = input)),
Result = Record.Field(Record,"Dec")
in
Result
in
fnHex2DecFromDBIn the example above, "MySQLServer" is the name of the SQL Server, "MyDatabase" is the name of the database. In that database on that server I have a table called "Hex2Dec" with two columns named "Hex" and "Dec". The rows are what you would imagine them to be for hex to decimial conversion. Basically, the premise here should work for any lookup situation that has unique lookup values. To use this, just create a new column with the formula:
=fnHex2DecFromDB([TextColumn])