Forum Discussion
Try to use OR function with if and text contains
Thank you for the solutions.
Will I be not able to call the function with multiple values in at a time? I have over 50 datacenters that needs categorization and the code looks cumbersome
It will be easy if I provide the the values in a single function rather than taking up multiple lines.
such as:
if Text.Contains([Data Center], OR("AB*, AC*") then "Europe"
or
if Text.StartsWith([Data Center],OR("AB*", "AC*") then "Europe"
or
if StartString = or("AB*", "AC*) then "Europe"
- DavidBI3 years agoRegular Visitor
Hello,
Wouldn't it make sense to have a separate lookup table in which you start all the datacenters and join this to the main table? This increases flexibility as i think an if clause is not best stuiable if you have over 50 cases.
- PhilipTreacy3 years ago
Super User
Hi rvnaresh
Yes you could write this as a function, called FindRegion
(DataCenter as text) => let DC = Text.Start(DataCenter , 2), Regions = [ AB = "Europe", AC = "Europe", BA = "Americas", BD = "Americas", CA = "APAC", CD = "APAC" ], Source = if Record.HasFields(Regions, DC) then Record.Field(Regions, DC) else "Uncategorized" in SourceYou'll need to add all of the data center codes and regions to the Regions record in this function.
You can then call it in a new Custom Column like this
= FindRegion([Data Center])regards
Phil
- rvnaresh3 years ago
Microsoft Employee
Thanks Phil..
will give it a try