<?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 DAX REST API - NullArray in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/DAX-REST-API-NullArray/m-p/2049559#M31454</link>
    <description>&lt;P&gt;My powershell code:&lt;/P&gt;&lt;PRE&gt;$requestUrl = "datasets/291666dc-09a2-44e3-ba8b-24b590fd9331/executeQueries"&lt;BR /&gt;&lt;BR /&gt;$requestBody = @"&lt;BR /&gt;{ “queries”: [{“query”:”EVALUATE SUMMARIZE('Calendar','Calendar'[Year],"Days in year",COUNT('Calendar'[Date]))“}], “serializerSettings”:{“incudeNulls”: true}}&lt;BR /&gt;"@&lt;BR /&gt;&lt;BR /&gt;Login-PowerBI&lt;BR /&gt;$result = Invoke-PowerBIRestMethod -Method Post -Url $requestUrl -Body $requestBody&lt;BR /&gt;$parsed = $result | ConvertFrom-Json&lt;BR /&gt;$parsed.results[0].tables[0].rows | Format-List&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;PRE&gt;Invoke-PowerBIRestMethod : One or more errors occurred.&lt;BR /&gt;At J:\test.ps1:35 char:11&lt;BR /&gt;+ $result = Invoke-PowerBIRestMethod -Method Post -Url $requestUrl -Bod ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException&lt;BR /&gt;+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod&lt;BR /&gt;&lt;BR /&gt;Cannot index into a null array.&lt;BR /&gt;At J:\test.ps1:38 char:1&lt;BR /&gt;+ $parsed.results[0].tables[0].rows | Format-List&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (:) [], RuntimeException&lt;BR /&gt;+ FullyQualifiedErrorId : NullArray&lt;/PRE&gt;&lt;P&gt;The error suggests that the DAX is wrong, but it's copy/pasted from the source .pbix file where it works fine.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jhayes0128_0-1630431969062.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/584445i744C9EBE99776168/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jhayes0128_0-1630431969062.png" alt="jhayes0128_0-1630431969062.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried these variations of the $requestUrl:&lt;/P&gt;&lt;PRE&gt;$requestUrl = "datasets/291666dc-09a2-44e3-ba8b-24b590fd9331/executeQueries"&lt;BR /&gt;$requestUrl = "https://api.powerbi.com/v1.0/myorg/datasets/291666dc-09a2-44e3-ba8b-24b590fd9331/executeQueries"&lt;BR /&gt;$requestUrl = "291666dc-09a2-44e3-ba8b-24b590fd9331/executeQueries"&lt;/PRE&gt;&lt;P&gt;And these variations of $requestBody:&lt;/P&gt;&lt;PRE&gt;EVALUATE SUMMARIZE('Calendar','Calendar'[Year],"Days in year",COUNT('Calendar'[Date]))&lt;BR /&gt;EVALUATE SUMMARIZE('Calendar','Calendar'[Year],\"Days in year\",COUNT('Calendar'[Date]))&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;add \ to "Days in year"&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;EVALUATE SUMMARIZE(Calendar,Calendar[Year],\"Days in year\",COUNT(Calendar[Date]))&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;remove ' from tablename and add \&lt;/EM&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have verified that 'Allow XMLA endpoints' and API permissions are granted. Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Microsoft Example:&amp;nbsp;&lt;A href="https://powerbi.microsoft.com/en-us/blog/announcing-the-public-preview-of-power-bi-rest-api-support-for-dax-queries/" target="_blank" rel="noopener"&gt;https://powerbi.microsoft.com/en-us/blog/announcing-the-public-preview-of-power-bi-rest-api-support-for-dax-queries/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Related thread:&lt;A href="https://community.powerbi.com/t5/Developer/New-API-Endpoint-with-DAX-Queries/m-p/1998477" target="_blank" rel="noopener"&gt;https://community.powerbi.com/t5/Developer/New-API-Endpoint-with-DAX-Queries/m-p/1998477&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Aug 2021 18:10:11 GMT</pubDate>
    <dc:creator>jhayes0128</dc:creator>
    <dc:date>2021-08-31T18:10:11Z</dc:date>
    <item>
      <title>DAX REST API - NullArray</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/DAX-REST-API-NullArray/m-p/2049559#M31454</link>
      <description>&lt;P&gt;My powershell code:&lt;/P&gt;&lt;PRE&gt;$requestUrl = "datasets/291666dc-09a2-44e3-ba8b-24b590fd9331/executeQueries"&lt;BR /&gt;&lt;BR /&gt;$requestBody = @"&lt;BR /&gt;{ “queries”: [{“query”:”EVALUATE SUMMARIZE('Calendar','Calendar'[Year],"Days in year",COUNT('Calendar'[Date]))“}], “serializerSettings”:{“incudeNulls”: true}}&lt;BR /&gt;"@&lt;BR /&gt;&lt;BR /&gt;Login-PowerBI&lt;BR /&gt;$result = Invoke-PowerBIRestMethod -Method Post -Url $requestUrl -Body $requestBody&lt;BR /&gt;$parsed = $result | ConvertFrom-Json&lt;BR /&gt;$parsed.results[0].tables[0].rows | Format-List&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;PRE&gt;Invoke-PowerBIRestMethod : One or more errors occurred.&lt;BR /&gt;At J:\test.ps1:35 char:11&lt;BR /&gt;+ $result = Invoke-PowerBIRestMethod -Method Post -Url $requestUrl -Bod ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException&lt;BR /&gt;+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod&lt;BR /&gt;&lt;BR /&gt;Cannot index into a null array.&lt;BR /&gt;At J:\test.ps1:38 char:1&lt;BR /&gt;+ $parsed.results[0].tables[0].rows | Format-List&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (:) [], RuntimeException&lt;BR /&gt;+ FullyQualifiedErrorId : NullArray&lt;/PRE&gt;&lt;P&gt;The error suggests that the DAX is wrong, but it's copy/pasted from the source .pbix file where it works fine.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jhayes0128_0-1630431969062.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/584445i744C9EBE99776168/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jhayes0128_0-1630431969062.png" alt="jhayes0128_0-1630431969062.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried these variations of the $requestUrl:&lt;/P&gt;&lt;PRE&gt;$requestUrl = "datasets/291666dc-09a2-44e3-ba8b-24b590fd9331/executeQueries"&lt;BR /&gt;$requestUrl = "https://api.powerbi.com/v1.0/myorg/datasets/291666dc-09a2-44e3-ba8b-24b590fd9331/executeQueries"&lt;BR /&gt;$requestUrl = "291666dc-09a2-44e3-ba8b-24b590fd9331/executeQueries"&lt;/PRE&gt;&lt;P&gt;And these variations of $requestBody:&lt;/P&gt;&lt;PRE&gt;EVALUATE SUMMARIZE('Calendar','Calendar'[Year],"Days in year",COUNT('Calendar'[Date]))&lt;BR /&gt;EVALUATE SUMMARIZE('Calendar','Calendar'[Year],\"Days in year\",COUNT('Calendar'[Date]))&amp;nbsp; &amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;add \ to "Days in year"&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;EVALUATE SUMMARIZE(Calendar,Calendar[Year],\"Days in year\",COUNT(Calendar[Date]))&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;remove ' from tablename and add \&lt;/EM&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have verified that 'Allow XMLA endpoints' and API permissions are granted. Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Microsoft Example:&amp;nbsp;&lt;A href="https://powerbi.microsoft.com/en-us/blog/announcing-the-public-preview-of-power-bi-rest-api-support-for-dax-queries/" target="_blank" rel="noopener"&gt;https://powerbi.microsoft.com/en-us/blog/announcing-the-public-preview-of-power-bi-rest-api-support-for-dax-queries/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Related thread:&lt;A href="https://community.powerbi.com/t5/Developer/New-API-Endpoint-with-DAX-Queries/m-p/1998477" target="_blank" rel="noopener"&gt;https://community.powerbi.com/t5/Developer/New-API-Endpoint-with-DAX-Queries/m-p/1998477&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Aug 2021 18:10:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/DAX-REST-API-NullArray/m-p/2049559#M31454</guid>
      <dc:creator>jhayes0128</dc:creator>
      <dc:date>2021-08-31T18:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: DAX REST API - NullArray</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/DAX-REST-API-NullArray/m-p/2055761#M31527</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/319766"&gt;@jhayes0128&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Refer to this code, you can try table expression which looks like {\"Calendar\"}.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 520px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/586674iDA1F418E411E3740/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Try this code in your reuqest body:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;EVALUATE SUMMARIZE({\"Calendar\"},'Calendar'[Year],\"Days in year\",COUNT('Calendar'[Date]))&lt;/PRE&gt;
&lt;P&gt;Based the related post, the end user solved his problems by using datasets in V2 workspace. You need build permission to use rest api for Dax Queries.&lt;/P&gt;
&lt;P&gt;For reference:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 686px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/586688i5D14FBDC3E44B838/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Please check what kind of workspace is your dataset in. Test datasets in your V2 workspace instead of My Workspace or V1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 07:34:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/DAX-REST-API-NullArray/m-p/2055761#M31527</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-03T07:34:17Z</dc:date>
    </item>
  </channel>
</rss>

