Forum Discussion

Alessandro-laba's avatar
5 years ago
Solved

If - Then - without Else

Hi everyone, 

 

I have a marketing database with thousands of email addresses and company names and I import all these data in Power Bi.

 

Unfortunately our system doesn't talk with our CRM and this is a problem cause when people go on our Power Bi dashboard they filter a company name using the one on our CRM system but it might happen that the company's name on Power Bi is different. An example would be like below:

 

Marketing

Company name = Water for Sport

 

CRM:

Company name = Water Sport

 

Now a way that I have found to fix this issue is using the conditional statement 'IF - Then' in Power Bi. For instance I can say: If email address contains @watersport.com then company name is 'Water for Sport'. 

 

The above logic works perfectly however in this type of statement there is then the option 'else'. This results to be a problem for my specific case cause as i said before I have thousands of companies and actually the ones I am interested to 'trim' are just around 200. If I proceed with this approach I will then loose all the other companies for which I don't set up a rule. 

 

I was wondering then if there is a way to use the 'If and then' statement ignoring the 'Else' command. Just to let you know if I leave the 'else' blank then all the other companies won't appear.

 

Thanks in advance, 

Alessandro

  • Hi Alessandro-laba 

    If you are doing this in Power Query and creating a Custom Column, then you are checking an existing column to check the email address.  If you don't find the text you are searching for, the else can just output this unmodified column - for example

     

    if Text.Contains([Email_Address] , "@watersport.com") then "Water for Sport" else [Email_Address]

     

    Phil

  • HiAlessandro-laba 

    I'm not sure I understand fully. You can perhaps  do something like:

    = if Text.Contains([emailaddress], "@watersport") then  "Water for Sport"  else [emailaddress]

     

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

3 Replies

  • AlB's avatar
    AlB
    Community Champion

    HiAlessandro-laba 

    I'm not sure I understand fully. You can perhaps  do something like:

    = if Text.Contains([emailaddress], "@watersport") then  "Water for Sport"  else [emailaddress]

     

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

  • Hi Alessandro-laba 

    If you are doing this in Power Query and creating a Custom Column, then you are checking an existing column to check the email address.  If you don't find the text you are searching for, the else can just output this unmodified column - for example

     

    if Text.Contains([Email_Address] , "@watersport.com") then "Water for Sport" else [Email_Address]

     

    Phil