Reputation: 622
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
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