Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
I was trying to figure out how to do a reverse concantination, per se, and got close...but can't get it right. 🙂
I have a long string of city/MSA information and I want to join this city table to another (state-level) table and decided to use 'State Abbreviation' as the bridge...used a bunch of SWITCHes to make "Flordia" become "FL" in a new column, for example.
So in short, I want to take the value in the [City/MSA/MD] column and truncate it to return the first two letters after/to the right of the comma, which will form the 'State Abbreviation' column.
You can see I got the "FL" in there perfectly...but also everything thereafter. 🙂
Could someone point out the error in my ways, please? Should I use something else (lookups?) to get at the two letters after the comma?
(I don't even want to address the MSAs that comprise MULTIPLE states, so just pulling the first two capital letters after the comma and assigning to that primary state...for now). lol
Solved! Go to Solution.
@Terp , On Top of your formula use left(<Current formula>,2)
I think that might help
Can you try adding the LEFT function to what you already have?
St Abbrv =
LEFT (
RIGHT ( [City/MSA/MD], LEN ( [City/MSA/MD] ) - FIND ( ", ", [City/MSA/MD] ) - 1 ),
2
)
This should get you the two characters on the left, of the text to the right of the comma.
If you have a static number of states that an entry can be at most (ie. no more than two/three states), you could probably add a conditional to check the third digit from the left, and if its a "-" then you have two states, and return the first 5 characters, otherwise return the first 2.
Your genius is equally impressive, thanks! 🙂
'Left (right...' just didn't seem right. Thank you both for the help...never would have stumbbled on that one.
It does seem like a strange combination.. I went ahead and threw together a mockup of how you could go about getting multiple states. This will only work if you have a static number of states; if its dynamic, then a bunch of nested if statements probably isn't efficient enough.
St Abbrv =
var rightOfComma = RIGHT([Column2], LEN([Column2]) - FIND(", ", [Column2])-1)
var thirdChar = RIGHT(LEFT(rightOfComma, 3), 1)
return
IF(
thirdChar = "-",
LEFT(rightOfComma, 5),
LEFT(rightOfComma, 2)
)
@Terp , On Top of your formula use left(<Current formula>,2)
I think that might help
You, sir, are a genius....would have NEVER gotten that one right...did swap out right for left previously and played around, but would have never thought to use both. 🙂
It doen't seem intuitive/efficient, but it sure works! Many, many thanks, sir!
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!