

How to Push Data via PowerShell to PowerBI - Petri
source link: https://petri.com/how-to-push-data-via-powershell-to-powerbi?utm_campaign=how-to-push-data-via-powershell-to-powerbi
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to Push Data via PowerShell to PowerBI
Subscribe to Petri NewslettersOffice 365 Insider
Petri.com may use your contact information to provide updates, offers and resources that may be of interest to you. You can unsubscribe at any time. To learn more about how we manage your data, you can read our Privacy Policy and Terms of Service.
!Already a Petri.com member? Login here for 1-click registration.
PowerBI has quickly become a top platform for data analytics within the Office 365 set of applications. With the ability to consume data from a variety of sources, manipulate, visualize, and publish that data, PowerBI stands out as an easy to use and powerful data visualization platform. With the ability to utilize PowerShell as a means to ingest data and manipulate PowerBI, system administrators and users alike gain powerful new abilities to utilize data through programmatic means. In this article, we explore how to send in data to a PowerBI dataset through PowerShell.
Installing and Connecting the PowerBI Module for PowerShell
Using the [MicrosoftPowerBIMgmt](<https://docs.microsoft.com/en-us/powershell/power-bi/overview?view=powerbi-ps>)
module and installed to the CurrentUser
scope, we can install PowerBI PowerShell tools without using administrator modules.
The next step will be connecting to the PowerBI workspace. You will use the Connect-PowerBIServiceAccount
and pass in the credentials that you use to login to your Office 365 tenant.
Now that we are connected, we need to create the dataset and structure.
Retrieving the PowerBI Workspace & Crafting a Dataset
We will use the Get-PowerBIWorkspace
cmdlet to retrieve the Id
of the workspace that we will be adding a dataset to and populating with data.
Retrieve the workspace to add the dataset to.
To create a dataset, think SQL database, within PowerBI we need to define a table for the data to populate and the columns, think fields, that the data will use.
This is all just setup, we haven’t actually created the dataset. To do so we need to use the Add-PowerBIDataSet
and pass in the constructed $DataSet
variable.
As you can see from the below screenshot, the dataset has been added into the Test Team and is now available.
Demonstrate that the dataset has been created in the workspace.
Without data, PowerBI is not that useful, so let’s discover how to add data via PowerShell!
Adding Data to the DataSet
Of course, to make any dataset useful, we need data. Using the Add-PowerBIRow
, we can add a row of data. There are two ways to add the data.
- Pipe in each individual row data
- Using the
Rows
parameter, pass in a bulk set of rows
Out of the two methods, the second which is passing in a bulk set of data, is the more efficient and preferred method.
Using the editor online, you can show that the data in a table. As you can see below, the three columns that we originally defined are shown with the values appropriately assigned.
Demonstrate that the data has been added to the dataset.
What about removing data from the dataset? Read on to learn how to remove rows.
Removing Rows of Data from a PowerBI DataSet
Unfortunately, you cannot remove a single row from a dataset. But you can clear the dataset and truncate the data. This is done using the Remove-PowerBIRow
. Why might you do this? If you need to change the structure of the dataset and repopulate the data is one reason. Let’s demonstrate this by using the command and adding a column to the dataset.
Now that the data has been cleared, we need to add a new column to the data and update the data. To update the schema we need to use the Set-PowerBITable
command.
Now that the data has been updated, let’s once again send in some data, but this time with the added Active
column.
As you can see in the below screenshot, the new column shows and with the updated data.
Show that the added column and data has been added.
Conclusion
PowerBI offers a powerful platform to manipulate and visualize data. With the ability to input data via PowerShell, the ability to send data from third-party tools and outside data sources becomes even easier. Explore all the ways to integrate data via PowerShell into PowerBI.
Recommend
-
25
There are many things the global coronavirus pandemic crisis has shown us, but there are a few things that stand out. One of them is that the current vaccine and drug development process takes a lot of time. Some would eve...
-
15
PowerBI & Big Data – Using pre-calculated Aggregations of Semi- and Non-Additive Measures Calculating and visualizing semi- and non-additive measures like distinct count in Power BI is usually not a big deal. H...
-
8
What's New in PowerShell 7.1 The latest versions of PowerShell are not included out-of-the-box with Windows 10. So, you might not know that PowerShell is already on version 7.1 The version in Windows 10 is called Windows...
-
5
With Windows 11, Everyone Gets Teams
-
10
-
13
The PowerBI Volleyball Report – Organizing Data To Start One of my goals this year was to build a repo...
-
19
Refresh PowerBI Datasets using PowerShell and Azure Runbooks In June 2017, Microsoft announced a new set...
-
9
How to Download a File using PowerShell PowerShell can download files from the Internet and your local network to your computer. Learn how to use PowerShell’s I...
-
6
Olaf Fischer October 14, 2022 1 minute read
-
7
在BI报表的设计中,配色方案往往成为一大难题,一组切合主题、搭配合理的颜色设计往往能为我们的报表,加分不少。 今天,就介绍一个AI配色的网站,利用AI为pbi报表进行配色设计。 一:网站网址 https://aicolors.co/
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK