简体   繁体   中英

How to define dataset coming from Power BI in Custom R Visual

I am trying to create a custom visual in Power BI based on an R script much like in the example found at ( http://radacad.com/interactive-map-using-r-and-power-bi-create-custom-visual-part-1 ), Installed node.js, pbiviz successfully. Once I get this custom visual in Power BI Desktop, I see all static data coming from sample iris dataset, But I want this to use my dataset coming from Power BI. how can I edit the script (shown below) to allow Power BI to use my own data rather than the data in the library?

source('./r_files/flatten_HTML.r')

############### Library Declarations ###############
libraryRequireInstall("ggplot2");
libraryRequireInstall("plotly")
####################################################

################### Actual code ####################
g = qplot(`Petal.Length`, data = iris, fill = `Species`, main = Sys.time());
####################################################

############# Create and save widget ###############
p = ggplotly(g);
internalSaveWidget(p, 'out.html');
####################################################

When I attempt to change "iris" to a dataset, it can't find dataset. I've also tried adding dataset <- data.frame(MyColumns) but that did not help.

If I have table name as Dim - Product, Fact - Sales and Columns as Product Name and Total Sales. How do I define this?

Any tutorial/video which has the example would really help.

Use cbind to create a dataframe with the objects you are sending from PBI. Assuming all the objects you are sending are mandatory:

dataset <- as.data.frame(cbind(var1,var2,...))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM