Power BI provides several options for importing data from various sources into its platform. These include:
* DirectQuery : This option allows you to create a live connection to a data source and visualize the data in real-time. No data is stored in Power BI, and all data remains in the source system.
* Import : This option allows you to import a copy of the data into Power BI and store it in the Power BI service. This option is best for small to medium-sized datasets that can be fully loaded into memory.
* Power BI Dataflows : This is a self-service ETL (extract, transform, and load) tool that allows you to connect to and cleanse data from a variety of sources, and then load the data into Power BI.
Here's a simple example of how to import data into Power BI using DirectQuery :
let dataSource = powerbi.data.createDataSource({
type: "sql",
connectionString: "Server=<serverName>;Database=<databaseName>;Trusted_Connection=True;",
table: "Sales"
});
powerbi.datasets.createDataset({
dataSource: dataSource,
tables: [{ name: "Sales", columns: [{ name: "Product", type: "string" }, { name: "Amount", type: "decimal" }] }]
})
.then(function (dataset) {
let report = powerbi.report({
data: dataset,
type: "pie",
options: {
dataLabels: {
fontSize: 20
},
legend: {
visible: false
}
}
});
powerbi.render(document.getElementById("container"), report);
});