Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Regex and python script

Hello, I'm trying to use a regex expression in power bi and python and it doesn't want to work... I want to find a text that is starting with a E and ending with a comma (,). Here my code :     ...
  • v-alq-msft's avatar
    6 years ago

    Hi, Anonymous 

     

    I'd like to suggest you achieve your requirement with dax. I created data to reproduce your scenario. The pbix file is attached in the end.

     

    Table:

     

    You may create a measure or a calculated column as below.

    Calculated column:
    Result Column = 
    var _text = 'Table'[Text]
    return
    IF(
        LEFT(_text,1)="E"&&RIGHT(_text,1)=",",
        _text
    )
    
    Measure:
    Result Measure = 
    var _text = SELECTEDVALUE('Table'[Text])
    return
    IF(
        LEFT(_text,1)="E"&&RIGHT(_text,1)=",",
        _text
    )

     

    Result:

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.