Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
I have a source column called Defect1Code which can contain any one of dozens of codes that follow this structure: G5.4.1 – Some Text Here. The length of the alphanumeric at the beginning varies, and in some cases the column for a given row may be blank altogether. All are acceptable possibilities.
I want to extract the alphanumeric out, so I am using this DAX:
Column = LEFT ([Defect1Code], (SEARCH (" ", [Defect1Code],, BLANK()))
This seems to work perfectly, but with one itty-bitty hitch: from what I can tell it also seems to be bringing over the first space after the last alphanumeric (i.e. “G5.4.1 “ – but without the quotes of course).
I thought adding a simple “-1” after the SEARCH would solve it, and it does except (and here’s the big problem) it treats BLANK returns as a ZERO, so in rows with a blank Defect1Code the SEARCH returns -1, which hoses up the LEFT function!
Am I missing a better solution?
Solved! Go to Solution.
Hi @Anonymous
Column =
VAR pos_ =
SEARCH ( " ", [Defect1Code],, BLANK () )
RETURN
IF ( NOT ISBLANK ( pos_ ), LEFT ( [Defect1Code], pos_ - 1 ) )
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Hi @Anonymous
Column =
VAR pos_ =
SEARCH ( " ", [Defect1Code],, BLANK () )
RETURN
IF ( NOT ISBLANK ( pos_ ), LEFT ( [Defect1Code], pos_ - 1 ) )
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Awesome - THANKS!
I dint think DAX is the best option here. Power Query is built to do these types of things. You should consider cleaning the columns in PQ before you load the data so it works to your needs without using functions like LEFT and SEARCH
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 74 | |
| 70 | |
| 39 | |
| 35 | |
| 23 |