Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
stephaniesmall
Regular Visitor

Power Bi & R Script Problem with Stringr displacing columns unintentionally

I built an r script using stringr that should build 2 columns, Salesforce & CRM1. It is performing as expected except for in some rows, it is moving & deleting data from cells that are not being called in the following code: 

 

library(stringr)

SFDC <- c("SFDC|Salesforce")

Dynamics <- c("Dynamics|Microsoft|365")

Oracle <-c("Oracle|On Demand|Ondemand")

SAP <- c("SAP|Siebel")

InHouse <- c("in house|internal|inhouse|proprietary")

Unknown <- c("don't know|unknown|not sure|not mention|can't remember")

None <- c("none|no crm|N/A")

dataset$salesforce <- str_replace_all(

  str_replace_all(

  str_replace_all(

  str_replace_all(

  str_replace_all(

  str_replace_all(

  str_replace_all(dataset$new_crmused, regex(SFDC, ignore_case=TRUE), "Salesforce"),

      regex(Dynamics, ignore_case=TRUE), "Dynamics"),

      regex(Oracle, ignore_case=TRUE), "Oracle"),

      regex(SAP, ignore_case=TRUE), "SAP Siebel"),

      regex(InHouse, ignore_case = TRUE), "In House System"),

      regex(Unknown, ignore_case = TRUE), "Unknown"),

      regex(None, ignore_case=TRUE), "None")

dataset$CRM1 <- str_extract(dataset$salesforce,"Salesforce|Dynamics|Oracle|SAP Siebel|In House System|Unknown|None")

 

Does anyone have any ideas why it is doing this?

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @stephaniesmall 

I'm not the expert of R, please check if it works as expected on R side, if not, you could ask questions in R forums.

 

Best Regards
Maggie

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.