Conner
Conner

Reputation: 307

How to use regular expressions in DAX formula?

I have a column in PowerBI that looks like this:

MyColumn
S01
S00
CAL
S00
S02
MOR
SIN

I want to create a new column that simply tells whether MyColumn is AlphaNumeric or just Alpha. So it would look like this:

MyColumn  MyNewColumn
S01       AlphaNumeric
S00       AlphaNumeric
CAL       Alpha
S00       AlphaNumeric
S02       AlphaNumeric
MOR       Alpha
SIN       Alpha 

Thank you in advance!

Upvotes: 1

Views: 15614

Answers (1)

Marco_CH
Marco_CH

Reputation: 3294

Power BI and Power Query doesn't support RegEx as we know it from R, Python or other Languages. Here is an article about to use Python in Power Query for using Regex:

Update: Another idea how we can use RegEx without Python or R is posted by Alexis Olson in the comments.

In DAX there are workarounds like the following:

MyNewColumn = if(ISERROR(VALUE(right(Tabelle1[MyColumn], 2))), "Alpha", "AlphaNumeric")

Output:

enter image description here

Upvotes: 2

Related Questions