iifNull with regexMatch

Mohamed Mohamed 66 Reputation points
2022-01-23T12:04:11.823+00:00

In Azure Data mapping, I have 3 columns for telephone numbers T1, T2 & T3.

I want to create another column TelephoneNumber that would return T1 if its not null and the value is in a certain match (to actual telephone numbers) and move on to T2 if the condition isnt met and to T3 lastly.

I tried to combine iifNull with regexMatch as follow

iifNull(
regexMatch(Telephone1,(+44|0044|0|44)(7)[4-9][0-9]{8}),
regexMatch(Telephone2,(+44|0044|0|44)(7)[4-9][0-9]{8}),
regexMatch(Telephone3,(+44|0044|0|44)(7)[4-9][0-9]{8})
)

But the outcome is Boolean not the Value.
167572-image.png
Could you help please! Thanks

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,603 questions
0 comments No comments
{count} votes

Accepted answer
  1. svijay-MSFT 5,201 Reputation points Microsoft Employee
    2022-01-24T09:47:03.603+00:00

    Hello @Mohamed Mohamed ,

    Thanks for the question and using MS Q&A platform.

    That's becasue the RegexMatch returns boolean . I worked on the expression below that may be used at your end in the derived column transformation.

    iifNull(  
        iif(  
            regexMatch(Telephone1, `(\+44|0044|0|44)(7)[4-9][0-9]{8}`),Telephone1,toString(null())  
            ),  
         iif(  
            regexMatch(Telephone2, `(\+44|0044|0|44)(7)[4-9][0-9]{8}`),Telephone2,toString(null())  
            ),  
         iif(  
            regexMatch(Telephone3, `(\+44|0044|0|44)(7)[4-9][0-9]{8}`),Telephone3,toString(null())  
            )  
    )  
    

    The idea is to match the regex - If true return the number value with column (Tx) - else move to the next column & repeat the step

    167832-image.png

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful