Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
I'm trying to add a column called ofInterest select postcodes that match RG, OX & SA, the column would contain a 1 if the match is found, or 0 if not found.
My code is:
import pandas as pd
import re
dataset["ofInterest"] = dataset["RegAddress.PostCode"].re.search("[SRO][AGX][0-9]")
I'm sure I've got this all wrong because I have very little experience of Python (I know REGEX quite well) - can anybody help me?
Hi @MarcusR1 ,
Has your problem been solved?If the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Neeko, unfortunately your solution doesn't work as REGEX becasue I need to look for any of the letters follwoed by a number (regexz /[SRO][AGX][0-9]/) but your suggestion doesn't do that.
all the best, Marcus
Hi @MarcusR1 ,
I'm sorry I can't understand your needs, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @MarcusR1 ,
According to your description, here are my steps you can follow as a solution.
(1)This is my test data.
Table:
Table(2):
And the relationships between tables:
(2)We can create a measure.
ofInterest = var _t = {"OX","RG","SA"} return IF( MAX('Table'[Type]) in _t , 1 ,0)
(3)Then the result is as follows.
Please refer to the following documents that may be helpful:
Using regular expressions in power bi desktop - Microsoft Power BI Community
Regular expressions in Power Query – Q-stat
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks Amit, I have posted it on the Python forum. I think it's still relevant here though, because the Table/Column structure is relevant to PowerBI, and hopefully if I find a solution it will help other PowerBI users.
As an aside, it would be great if PowerBI supported REGEX in DAX or PowerQuery 😉
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 23 | |
| 21 | |
| 20 | |
| 18 | |
| 13 |
| User | Count |
|---|---|
| 58 | |
| 50 | |
| 38 | |
| 31 | |
| 27 |