Rajesh Kumar
Rajesh Kumar

Reputation: 622

Can I create Dataset in power BI Using Power Shell

Actually I want to create dataset by using PowerShell, suppose I don't want to use power BI desktop to create Dataset and data source.

Upvotes: 0

Views: 348

Answers (1)

Andrey Nikolov
Andrey Nikolov

Reputation: 13450

Yes, you can create a dataset either using Power BI REST API's PostDatasetInGroup (using it with Invoke-RestMethod) or using Microsoft's official Power BI Management module and Add-PowerBIDataset cmdlet in particular.

For example, something like that:

Login-PowerBI

$col1 = New-PowerBIColumn -Name ID -DataType Int64
$col2 = New-PowerBIColumn -Name Data -DataType String
$table1 = New-PowerBITable -Name SampleTable1 -Columns $col1,$col2

$col3 = New-PowerBIColumn -Name ID -DataType Int64
$col4 = New-PowerBIColumn -Name Date -DataType DateTime
$col5 = New-PowerBIColumn -Name Detail -DataType String
$col6 = New-PowerBIColumn -Name Result -DataType Double
$table2 = New-PowerBITable -Name SampleTable2 -Columns $col3,$col4,$col5,$col6

$dataset = New-PowerBIDataSet -Name SampleDataSet -Tables $table1,$table2

Add-PowerBIDataSet -DataSet $dataset

Upvotes: 1

Related Questions