Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
lbendlin
Super User
Super User

Dealing with blanks when consuming REST API DAX query results

I am working on a process to extract data from Power BI datasets via the REST API

 

Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Docs

 

This works nicely and I can receive the resulting JSON fine, with the rows and columns of the result set coded as needed. However if the result set has blanks in some cells then the JSON will omit those properties (column values) for the affected rows.

 

{
  "results": [
    {
      "tables": [
        {
          "rows": [
            {
              "[Week_Starting]": "12 Dec",
              "[Report Date]": "2021-12-08T00:00:00",
              "[Amount]": 14
            },
            {
              "[Week_Starting]": "05 Dec",
              "[Report Date]": "2021-12-08T00:00:00",
              "[Amount]": 88
            },
            {
              "[Report Date]": "2021-12-08T00:00:00",
              "[Amount]": 52
            },
            {
              "[Week_Starting]": "Previous",
              "[Report Date]": "2021-12-08T00:00:00",
              "[Amount]": 41
            }
          ]
        }
      ]
    }
  ]
}

Note that the third row is missing the "[Week_Starting]"  property as that data point is indeed BLANK in the Power BI Dataset.

 

Now I want to push that JSON result to a SQL server table.  Unfortunately that server runs on compatibility level 110 so OPENJSON is not available.  So my workaround was to ingest the JSON into a powershell PSObject 

 

$rows = $res.Substring(3) | ConvertFrom-Json | Select-Object -Expand results  | Select-Object -Expand tables  | Select-Object -Expand rows

 

and then push that PSObject into the SQL table via 

 

$rows | Write-SqlTableData -ServerInstance "server" -DatabaseName "detabase" -SchemaName "dbo" -TableName "table"

 

This works for all rows except for the row with the blank - it will not get imported.

 

I am looking for options to either replenish the missing property (for example by patching the PSObject) or to ingest the data anyway.  I had thought about changing the DAX query but haven't been successful yet as that particular BLANK would require me to rewrite the entire data model.

 

Has anyone worked on this topic (fetching query results into SQL Server table) yet?

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @lbendlin ,

I'm wondering if you have considered the property "DatasetExecuteQueriesSerializationSettings"
Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Docs


Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

3 REPLIES 3
TomMartens
Super User
Super User

Hey @lbendlin ,

I'm wondering if you have considered the property "DatasetExecuteQueriesSerializationSettings"
Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Docs


Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

D'oh.  "Wer lesen kann, ist klar im Vorteil."

Thank you.

Hey @lbendlin ,

 

I wasn't aware of your perfect German 😉

 

Frohe Weihnachten!

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.