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 moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi All,
I'm trying to make use of the R scripting option to make some visualisations, but it's presenting some fairly serious issues.
For starters, the fact Power BI replaces underscores in field names with spaces means that R has a very hard time actually doing any of the things it's been included for (ggplot2, for example, really doesn't like spaces, so "just use the full name" as suggested here won't cut it).
Is there any way of forcing Power BI to take field names exactly as they're written in source rather than trying to be "helpful" and add spaces?
Failing that, have people had much success with renaming columns (either using the plyr package or more manually) in Power BI?
Alternatively, is there a way of editing the "#create dataframe" section of an R script in Power BI? (so that I can manually define my column names).
Semi-relatedly, is there any plan to include the make.names function in the R dataset definition going forward?
Thanks,
George
Solved! Go to Solution.
On closer inspection it appears the spaces are automatically inserted at some point during the OLAP/MDX level rather than by PowerBI itself, however that doesn't really help resolve the problem.
Regardless of how the spaces are being inserted, I still need to get rid of them in R.
EDIT:
on testing it appears that the following solves the problem:
names(dataset) <- gsub(" ","_",names(dataset))
I am not seeing the underscores replaced by spaces. I imported from a CSV file and the columns came in with the underscores. Can you provide more details around source or exactly when/where you are seeing the underscores replaced?
On closer inspection it appears the spaces are automatically inserted at some point during the OLAP/MDX level rather than by PowerBI itself, however that doesn't really help resolve the problem.
Regardless of how the spaces are being inserted, I still need to get rid of them in R.
EDIT:
on testing it appears that the following solves the problem:
names(dataset) <- gsub(" ","_",names(dataset))
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.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 43 | |
| 39 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 63 | |
| 32 | |
| 30 | |
| 23 |