<?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 Re: Multiple Connections Dax Query in Report Server</title>
    <link>https://community.fabric.microsoft.com/t5/Report-Server/Multiple-Connections-Dax-Query/m-p/1006328#M13685</link>
    <description>&lt;P&gt;Thank's&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="109790" data-lia-user-login="d_gosbell" class="lia-mention lia-mention-user"&gt;d_gosbell&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;can you show me an example? I can't execute any powershell script without warnings..I try to install also nuget package..but seems not work..&lt;/P&gt;</description>
    <pubDate>Fri, 03 Apr 2020 07:17:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-04-03T07:17:47Z</dc:date>
    <item>
      <title>Multiple Connections Dax Query</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Multiple-Connections-Dax-Query/m-p/1005216#M13669</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a premium workspace with various pubblications of the same app (same tables, model, but different dataset).&lt;/P&gt;&lt;P&gt;If I connect with SQL Server Management Studio I can see all dataset correctly. There is a way to execute a query in all dataset?&lt;/P&gt;&lt;P&gt;for example, i need to know how many rows has a table in each dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank's&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 15:48:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Multiple-Connections-Dax-Query/m-p/1005216#M13669</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-02T15:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Connections Dax Query</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Multiple-Connections-Dax-Query/m-p/1005743#M13676</link>
      <description>&lt;P&gt;No, you cannot do this in DAX. Other than manually changing the connection, the only option I can think of would be to use something like a PowerShell script where you could loop across each dataset and run a set of queries.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 22:42:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Multiple-Connections-Dax-Query/m-p/1005743#M13676</guid>
      <dc:creator>d_gosbell</dc:creator>
      <dc:date>2020-04-02T22:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Connections Dax Query</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Multiple-Connections-Dax-Query/m-p/1006328#M13685</link>
      <description>&lt;P&gt;Thank's&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="109790" data-lia-user-login="d_gosbell" class="lia-mention lia-mention-user"&gt;d_gosbell&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;can you show me an example? I can't execute any powershell script without warnings..I try to install also nuget package..but seems not work..&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 07:17:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Multiple-Connections-Dax-Query/m-p/1006328#M13685</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-03T07:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Connections Dax Query</title>
      <link>https://community.fabric.microsoft.com/t5/Report-Server/Multiple-Connections-Dax-Query/m-p/1008990#M13713</link>
      <description>&lt;P&gt;OK so the following is &lt;STRONG&gt;really&lt;/STRONG&gt; rough, but if you change the value of the $workspace variable (currently set to "Xmla Test") it should work for you. It loops through all the DataSets (which it gets from the DBSCHEMA_CATALOGS DMV) and then it outputs all the row counts for all the tables in each dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt; #load the type from the Microsoft.AnalysisServices.AdomdClient nuget package
Install-Package Microsoft.AnalysisServices.AdomdClient.retail.amd64 -Source "https://www.nuget.org/api/v2"
$p = get-package Microsoft.AnalysisServices.AdomdClient.retail.amd64
$nugetFile = get-childitem $p.source
$adomdFile = join-path $nugetFile.DirectoryName "lib\net45\Microsoft.AnalysisServices.AdomdClient.dll"
add-type -path $adomdFile

## Query Power BI using XMLA Endpoint to get a list of data sets
$workspace = "Xmla Test"
$connStr = "Data Source=powerbi://api.powerbi.com/v1.0/myorg/$($workspace)"
$conn = new-object Microsoft.AnalysisServices.AdomdClient.AdomdConnection $connStr
$cmd = $conn.CreateCommand()
$cmd.CommandText = "SELECT [CATALOG_NAME] from `$SYSTEM.DBSCHEMA_CATALOGS" 
$da = new-object Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter $cmd
$dataSets = New-Object System.Data.DataTable("Tables")
$da.Fill($dataSets)
$dataSets | Format-Table


## for each data set loop over the tables and output the row counts
foreach ($dataSet in $dataSets)
{
    $datasetName = $dataSet["CATALOG_NAME"];
    write-host "Connecting to DataSet: $datasetName" -ForegroundColor Cyan
    $connStr = "Data Source=powerbi://api.powerbi.com/v1.0/myorg/$($workspace);Initial Catalog=$($datasetName)";
    $conn = new-object Microsoft.AnalysisServices.AdomdClient.AdomdConnection $connStr
    $cmd2 = $conn.CreateCommand()
    $cmd2.CommandText = "SELECT [Name] FROM `$SYSTEM.TMSCHEMA_TABLES" 
    $da2 = new-object Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter $cmd2
    $tables = New-Object System.Data.DataTable("Tables")
    $da2.Fill($tables) &amp;gt; $null

    $tableCmd = ""

    foreach( $t in $tables)
    {
        if ($tableCmd.Length -gt 0) { $tableCmd += "," }
        $tableCmd += "( `"$($t.Name)`", COUNTROWS( '$($t.Name)' ) )`n"
    }

    $tableCmd = "EVALUATE {" + $tableCmd + "}"
    $cmd3 = $conn.CreateCommand()
    $cmd3.CommandText = $tableCmd  
    $da3 = new-object Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter $cmd3
    $rowCounts = New-Object System.Data.DataTable("Tables")
    $da3.Fill($rowCounts) &amp;gt; $null
    
    ## echo out the results
    $rowCounts | Format-Table

}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 02:38:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Report-Server/Multiple-Connections-Dax-Query/m-p/1008990#M13713</guid>
      <dc:creator>d_gosbell</dc:creator>
      <dc:date>2020-04-06T02:38:07Z</dc:date>
    </item>
  </channel>
</rss>

