PowerShell – Adding a Dataset

PowerShell Scripts for creating and adding a dataset, columns and table.

Add PBIDataset

New-PowerBIColumn ---- creates a column
New-PowerBITable ----- creates a table
New-PowerBIDataSet ---- creates a dataset
Add-PowerBIDataset ----- adds a dataset


$ is used to declare a variable

Creating a Dataset

PS C:\"your path here"> $col1 = new-powerbicolumn -Name Name -Datatype String
>> $col2 = New-PowerBIColumn -Name ID -DataType Int64
>> $col3 = New-PowerBIColumn -Name Gender -DataType String
>> $table_primary = New-PowerBITable -Name main_table -Columns $col1,$col2,$col3
>>
>> $col4 = New-PowerBIColumn -Name ID -DataType Int64
>> $col5 = New-PowerBIColumn -Name Date -DataType DateTime
>> $col6 = New-PowerBIColumn -Name Detail -DataType String
>> $col7 = New-PowerBIColumn -Name Result -DataType Double
>> $table_secondary = New-PowerBITable -Name secondary_table -Columns $col4,$col5,$col6,$col7
>>
>> $dataset = New-PowerBIDataset -Name Meansh_Sample -Tables $table_primary, $table_secondary
>>
>> Add-PowerBIDataset -Dataset $dataset -WorkspaceId "provide workspaceID"


{

	$ is used to define a variable 
	new-powerbicolumn --- inbuilt cmdlet
	new-powerbitable --- inbuilt cmdlet
	new-powerbidataset --- inbuilt cmdlet
	
	
define a columns first, requires name and datatype

define a table and required which columns will be part of it

define a dataset and requires which tables will be part of it as well as the name of the data set 
	
	Finally do 

Add-PowerBIDataset command and provide the id for the workspace ----- if no name is given then the dataset will be created in "MyWorkspace" 

else if the name is provided then it will be a part of that workspace.
	
}	


 $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

Comments

Leave a Reply

Discover more from My journey from Datum to Data

Subscribe now to keep reading and get access to the full archive.

Continue reading