<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic PowerShell How to delete rows in dataset in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/PowerShell-How-to-delete-rows-in-dataset/m-p/1396780#M16113</link>
    <description>&lt;P&gt;I currently have a powershell that runs to update my data.&amp;nbsp; &amp;nbsp;I need to modify to delete all the rows in the dataset first and then get all new.&amp;nbsp; &amp;nbsp;I've NEVER used powershell so I''m a little lost.&amp;nbsp; &amp;nbsp;I found the code on a site and it works perfectly but I need to add in the piece to delete all rows first.&amp;nbsp; &amp;nbsp; Below is my script.&amp;nbsp; &amp;nbsp;Can someone PLEASE PLEASE add in the piece I need?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$dataSource = 'XXXXXX' #Server Name&lt;BR /&gt;$userName = 'XXXXX' #SQL User Name&lt;BR /&gt;$password = 'XXXXXX' #SQL User Password&lt;BR /&gt;$database = 'XXXXXXX' #Database Name&lt;BR /&gt;#Uncomment below connection string to use windows credentials&lt;BR /&gt;$connectionString = "Data Source=$dataSource;Initial Catalog=$database;Integrated Security=SSPI"&lt;BR /&gt;#Uncomment below connection string to use SQL Server authentication&lt;BR /&gt;#$connectionString ="Server=$dataSource;Database=$database;trusted_connection=false; user id =$userName;Password=$password;Integrated Security=False"&lt;BR /&gt;$connection = New-Object System.Data.SqlClient.SqlConnection&lt;BR /&gt;$connection.ConnectionString = $connectionString&lt;BR /&gt;$connection.Open()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;$query = '&lt;BR /&gt;SELECT * from BI_SOLD_RECAP;'&lt;BR /&gt;$command = $connection.CreateCommand()&lt;BR /&gt;$command.CommandText = $query&lt;BR /&gt;$dataset = $command.ExecuteReader()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#paste the endpoint URL which you have inside Power BI&lt;BR /&gt;$endpoint = "&lt;A href="https://api.powerbi.com/beta/54e2bd33-9277-490e-9932-e1b5a2cfabb2/datasets/f0ee56bf-5c15-45e1-85a2-eb32b273a56e/rows?key=z%2BLI4fQkPeYrUHDP5bDCkMBnHVsVxskJB48B2P0Ui3hOJJOuNcbYxZn9%2BD2gKJPp90o1qedZ7hd1p74V8WmZWw%3D%3D" target="_blank" rel="noopener"&gt;https://api.powerbi.com/beta/54e2bd33-9277-490e-9932-e1b5a2cfabb2/datasets/f0ee56bf-5c15-45e1-85a2-eb32b273a56e/rows?key=z%2BLI4fQkPeYrUHDP5bDCkMBnHVsVxskJB48B2P0Ui3hOJJOuNcbYxZn9%2BD2gKJPp90o1qedZ7hd1p74V8WmZWw%3D%3D&lt;/A&gt;"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#push data to Power BI&lt;BR /&gt;while ($dataset.Read()) {&lt;BR /&gt;$payload = @{&lt;BR /&gt;"EventCode" =$dataset['EventCode']&lt;BR /&gt;"EventName" =$dataset['EventName']&lt;BR /&gt;"EventDetail" =$dataset['EventDetail']&lt;BR /&gt;"PerformanceID" =$dataset['PerformanceID']&lt;BR /&gt;"PerformanceName" =$dataset['PerformanceName']&lt;BR /&gt;"PerfDateTime" =$dataset['PerfDateTime']&lt;BR /&gt;"SalesChannel" =$dataset['SalesChannel']&lt;BR /&gt;"SaleDateOnly" =$dataset['SaleDateOnly']&lt;BR /&gt;"SaleDate_DOW" =$dataset['SaleDate_DOW']&lt;BR /&gt;"SaleDate_Month" =$dataset['SaleDate_Month']&lt;BR /&gt;"Quantity" =$dataset['Quantity']&lt;BR /&gt;"ServiceFees" =$dataset['ServiceFees']&lt;BR /&gt;"ServiceFeesQuantity" =$dataset['ServiceFeesQuantity']&lt;BR /&gt;"DeliveryFees" =$dataset['DeliveryFees']&lt;BR /&gt;"DeliveryFeesQuantity" =$dataset['DeliveryFeesQuantity']&lt;BR /&gt;"TicketCost" =$dataset['TicketCost']&lt;BR /&gt;"TotalAmount" =$dataset['TotalAmount']&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload))&lt;BR /&gt;}&lt;BR /&gt;$connection.Close();&lt;BR /&gt;$connection.Dispose();&lt;/P&gt;</description>
    <pubDate>Sat, 26 Sep 2020 02:18:40 GMT</pubDate>
    <dc:creator>kdixon5490</dc:creator>
    <dc:date>2020-09-26T02:18:40Z</dc:date>
    <item>
      <title>PowerShell How to delete rows in dataset</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/PowerShell-How-to-delete-rows-in-dataset/m-p/1396780#M16113</link>
      <description>&lt;P&gt;I currently have a powershell that runs to update my data.&amp;nbsp; &amp;nbsp;I need to modify to delete all the rows in the dataset first and then get all new.&amp;nbsp; &amp;nbsp;I've NEVER used powershell so I''m a little lost.&amp;nbsp; &amp;nbsp;I found the code on a site and it works perfectly but I need to add in the piece to delete all rows first.&amp;nbsp; &amp;nbsp; Below is my script.&amp;nbsp; &amp;nbsp;Can someone PLEASE PLEASE add in the piece I need?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$dataSource = 'XXXXXX' #Server Name&lt;BR /&gt;$userName = 'XXXXX' #SQL User Name&lt;BR /&gt;$password = 'XXXXXX' #SQL User Password&lt;BR /&gt;$database = 'XXXXXXX' #Database Name&lt;BR /&gt;#Uncomment below connection string to use windows credentials&lt;BR /&gt;$connectionString = "Data Source=$dataSource;Initial Catalog=$database;Integrated Security=SSPI"&lt;BR /&gt;#Uncomment below connection string to use SQL Server authentication&lt;BR /&gt;#$connectionString ="Server=$dataSource;Database=$database;trusted_connection=false; user id =$userName;Password=$password;Integrated Security=False"&lt;BR /&gt;$connection = New-Object System.Data.SqlClient.SqlConnection&lt;BR /&gt;$connection.ConnectionString = $connectionString&lt;BR /&gt;$connection.Open()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;$query = '&lt;BR /&gt;SELECT * from BI_SOLD_RECAP;'&lt;BR /&gt;$command = $connection.CreateCommand()&lt;BR /&gt;$command.CommandText = $query&lt;BR /&gt;$dataset = $command.ExecuteReader()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#paste the endpoint URL which you have inside Power BI&lt;BR /&gt;$endpoint = "&lt;A href="https://api.powerbi.com/beta/54e2bd33-9277-490e-9932-e1b5a2cfabb2/datasets/f0ee56bf-5c15-45e1-85a2-eb32b273a56e/rows?key=z%2BLI4fQkPeYrUHDP5bDCkMBnHVsVxskJB48B2P0Ui3hOJJOuNcbYxZn9%2BD2gKJPp90o1qedZ7hd1p74V8WmZWw%3D%3D" target="_blank" rel="noopener"&gt;https://api.powerbi.com/beta/54e2bd33-9277-490e-9932-e1b5a2cfabb2/datasets/f0ee56bf-5c15-45e1-85a2-eb32b273a56e/rows?key=z%2BLI4fQkPeYrUHDP5bDCkMBnHVsVxskJB48B2P0Ui3hOJJOuNcbYxZn9%2BD2gKJPp90o1qedZ7hd1p74V8WmZWw%3D%3D&lt;/A&gt;"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#push data to Power BI&lt;BR /&gt;while ($dataset.Read()) {&lt;BR /&gt;$payload = @{&lt;BR /&gt;"EventCode" =$dataset['EventCode']&lt;BR /&gt;"EventName" =$dataset['EventName']&lt;BR /&gt;"EventDetail" =$dataset['EventDetail']&lt;BR /&gt;"PerformanceID" =$dataset['PerformanceID']&lt;BR /&gt;"PerformanceName" =$dataset['PerformanceName']&lt;BR /&gt;"PerfDateTime" =$dataset['PerfDateTime']&lt;BR /&gt;"SalesChannel" =$dataset['SalesChannel']&lt;BR /&gt;"SaleDateOnly" =$dataset['SaleDateOnly']&lt;BR /&gt;"SaleDate_DOW" =$dataset['SaleDate_DOW']&lt;BR /&gt;"SaleDate_Month" =$dataset['SaleDate_Month']&lt;BR /&gt;"Quantity" =$dataset['Quantity']&lt;BR /&gt;"ServiceFees" =$dataset['ServiceFees']&lt;BR /&gt;"ServiceFeesQuantity" =$dataset['ServiceFeesQuantity']&lt;BR /&gt;"DeliveryFees" =$dataset['DeliveryFees']&lt;BR /&gt;"DeliveryFeesQuantity" =$dataset['DeliveryFeesQuantity']&lt;BR /&gt;"TicketCost" =$dataset['TicketCost']&lt;BR /&gt;"TotalAmount" =$dataset['TotalAmount']&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload))&lt;BR /&gt;}&lt;BR /&gt;$connection.Close();&lt;BR /&gt;$connection.Dispose();&lt;/P&gt;</description>
      <pubDate>Sat, 26 Sep 2020 02:18:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/PowerShell-How-to-delete-rows-in-dataset/m-p/1396780#M16113</guid>
      <dc:creator>kdixon5490</dc:creator>
      <dc:date>2020-09-26T02:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: PowerShell How to delete rows in dataset</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/PowerShell-How-to-delete-rows-in-dataset/m-p/1400427#M16130</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="14013" data-lia-user-login="kdixon5490" class="lia-mention lia-mention-user"&gt;kdixon5490&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I currently have a powershell that runs to update my data.&amp;nbsp; &amp;nbsp;I need to modify to delete all the rows in the dataset first and then get all new.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't think this is possible using a script unless you are using a premium workspace. But this is exactly what a standard scheduled refresh does. Have you tried just configuring a normal scheduled refresh?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 22:14:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/PowerShell-How-to-delete-rows-in-dataset/m-p/1400427#M16130</guid>
      <dc:creator>d_gosbell</dc:creator>
      <dc:date>2020-09-28T22:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: PowerShell How to delete rows in dataset</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/PowerShell-How-to-delete-rows-in-dataset/m-p/1448359#M16380</link>
      <description>&lt;P&gt;Hi, &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="14013" data-lia-user-login="kdixon5490" class="lia-mention lia-mention-user"&gt;kdixon5490&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Why don't use REST API?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 03:54:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/PowerShell-How-to-delete-rows-in-dataset/m-p/1448359#M16380</guid>
      <dc:creator>DavisBI</dc:creator>
      <dc:date>2020-10-22T03:54:54Z</dc:date>
    </item>
  </channel>
</rss>

