I would like to return all the mac addresses into a new column as a list so that within Power query I can extract them to new lines.
Here is my Power Query code form within Power Query Editor.
Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
I would like to return all the mac addresses into a new column as a list so that within Power query I can extract them to new lines.
Here is my Power Query code form within Power Query Editor.
# 'dataset' holds the input data for this script
# Variables
pattern <- "([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})|([0-9a-fA-F]{4}\\.[0-9a-fA-F]{4}\\.[0-9a-fA-F]{4})"
# Functions
getMacs <- function(x) {paste(unlist(regmatches(x, gregexpr(pattern, x))))}
# Return
output <- within(dataset,{MACs1=getMacs(dataset$NICs)})
What I get returned into my new Macs1 column is the very first mac address from the NICs column of each row. I can't for the life of me figure out how to return all of the mac addresses as a list.
I have verified using Visual Studio Code that the regular expression works and that the R code does return all mac addresses as a character vector.
Doing some research I believe I need to convert the character vector to a data.frame before returning it to Power BI. I tried amending the following lines without success.
output <- within(dataset,{MACs1=as.list(getMacs(dataset$NICs))})
output <- within(dataset,{MACs1=as.data.frame(getMacs(dataset$NICs))})
I know it's going to be some #newbieFail but I just can't seem to figure it out. Appreciate any pointers or advice.
Thanks in advance. Cheers
Solved! Go to Solution.
@FlyKick You can run regex directly in Power BI now, without needing native R/stringR
check out these two links
@FlyKick You can run regex directly in Power BI now, without needing native R/stringR
check out these two links
This is awesome! Completely bypasses the need to use R. Thank you
Where does Power BI get the MAC addresses from in the first place? Are you running your R script in Power Query or in a visual?
Please provide sanitized sample data that fully covers your issue. Paste the data into a table in your post or use one of the file services. Please show the expected outcome.
Check out the April 2026 Power BI update to learn about new features.
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.
| User | Count |
|---|---|
| 48 | |
| 40 | |
| 38 | |
| 20 | |
| 16 |
| User | Count |
|---|---|
| 68 | |
| 67 | |
| 30 | |
| 26 | |
| 26 |