Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
 
					
				
		
Hi,
I'm trying to fix phone number formats to the preferred ###-###-#### format.
I would like to know which of the raw phone numbers (left column) already match the formatted numbers I built (right column).
I have tried the IF and CONTAINSSTRINGEXACT. All rows return true even though the formatted phone numbers have hyphens.
There are two tables. List whichs contains a mix of correct and in correct formatted numbers and Phone which contains the formatted numbers.
Solved! Go to Solution.
@Anonymous - Try this, I have included the PBIX below sig.
Column = 
    VAR __First3 = LEFT([Column1],3)
    VAR __FirstSep = MID([Column1],4,1)
    VAR __Second3 = MID([Column1],5,3)
    VAR __SecondSep = MID([Column1],8,1)
    VAR __Third4 = RIGHT([Column1],4)
RETURN
    SWITCH(TRUE(),
        NOT(ISERROR(__First3+0)) && LEN(__First3) = 3 && NOT(CONTAINSSTRING(__First3,"-")) && NOT(ISERROR(__Second3+0)) && LEN(__Second3)=3 && NOT(CONTAINSSTRING(__Second3,"-")) && NOT(ISERROR(__Third4+0)) && LEN(__Third4) = 4 && NOT(CONTAINSSTRING(__Third4,"-")) && __FirstSep = "-" && __SecondSep = "-", TRUE(),
        FALSE()
    ) 
					
				
		
Looking for help with adjusting the awesome work of Greg Deckler. I need to modify his code below to show that this phone format is "true" (###) ###-#### instead of my original request of ###-###-####
Column = 
    VAR __First3 = LEFT([Column1],3)
    VAR __FirstSep = MID([Column1],4,1)
    VAR __Second3 = MID([Column1],5,3)
    VAR __SecondSep = MID([Column1],8,1)
    VAR __Third4 = RIGHT([Column1],4)
RETURN
    SWITCH(TRUE(),
        NOT(ISERROR(__First3+0)) && LEN(__First3) = 3 && NOT(CONTAINSSTRING(__First3,"-")) && NOT(ISERROR(__Second3+0)) && LEN(__Second3)=3 && NOT(CONTAINSSTRING(__Second3,"-")) && NOT(ISERROR(__Third4+0)) && LEN(__Third4) = 4 && NOT(CONTAINSSTRING(__Third4,"-")) && __FirstSep = "-" && __SecondSep = "-", TRUE(),
        FALSE()
    ) 
					
				
		
@Greg_Deckler that's amazing! Thank you so much. I always enjoy reading your replies to folks. Truly helpful for me to continue my learning.
@Anonymous - Try this, I have included the PBIX below sig.
Column = 
    VAR __First3 = LEFT([Column1],3)
    VAR __FirstSep = MID([Column1],4,1)
    VAR __Second3 = MID([Column1],5,3)
    VAR __SecondSep = MID([Column1],8,1)
    VAR __Third4 = RIGHT([Column1],4)
RETURN
    SWITCH(TRUE(),
        NOT(ISERROR(__First3+0)) && LEN(__First3) = 3 && NOT(CONTAINSSTRING(__First3,"-")) && NOT(ISERROR(__Second3+0)) && LEN(__Second3)=3 && NOT(CONTAINSSTRING(__Second3,"-")) && NOT(ISERROR(__Third4+0)) && LEN(__Third4) = 4 && NOT(CONTAINSSTRING(__Third4,"-")) && __FirstSep = "-" && __SecondSep = "-", TRUE(),
        FALSE()
    )@Greg_Deckler Hi again Greg, the developer of our data source is not switching to using (###) ###-#### for proper phone formatting. Could you please help me convert the above code which populates my true/false column?
The original "true" value looked for ###-###-####
Thank you in advance for a reply!
Jim
 
					
				
				
			
		
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
 
            | User | Count | 
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | 
| User | Count | 
|---|---|
| 23 | |
| 12 | |
| 11 | |
| 10 | |
| 9 |