Forum Discussion
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 :
regex=r'(^E+.+,$)'
dataset['Sprint']=dataset['URL'].str.extract(regex)
Thanks 🙂
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.
3 Replies
- amitchandakSuper User
Anonymous , refer if this can help
- AnonymousNot applicable
Thanks but I would like to do it with Python not R...
- v-alq-msftCommunity Support
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.