Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! 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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 11 | |
| 10 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 19 | |
| 12 | |
| 11 |