Forum Discussion
rvnaresh
Microsoft Employee
3 years agoTry to use OR function with if and text contains
Hi, I want to categorize the datacenter to a region like the table below and use it in one of my reports. Datacenter Location ABC01 Europe ABC02 Europe ACB01 Europe ACB02 Eur...
rvnaresh
Microsoft Employee
3 years agoThank 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"
PhilipTreacy
Super User
3 years agoHi 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
Source
You'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