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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
adeelaziz
Frequent Visitor

How to handle no results coming back from Azure Resource Graph Query in Power Bi

We are using Azure tags extensively in our environment.  I have some ARG queiries that look for specific tags and check to see if the values are correct.  A simiplied version of the query is as follows:

 

(resources 
| where tags['ApplicationName'] !='3Par' and tags['ApplicationName'] !='Active Directory'and tags['ApplicationName'] != 'Clarity'
| project id, name, tags['ApplicationName'], tags, subscriptionId,resourceGroup)
 
 This returns all resources that don't contain those specific ApplicationName tag values.  I then added this query to Power Bi and it returned the same results, great!  Now the problem is that we have fixed the resources that didn't have the correct tag values and the ARG query returns no results.  Unfortunately Power Bi doesn't like this, it returns a table with a single row and column.  The column name is Results and the value is no results.
 
I modified the M query to check if the query is returning nothing back, if it is then to return a dummy table instead with the headings.
 
let
Source = AzureResourceGraph.Query("(resources #(lf)| where tags['ApplicationName'] != '3Par' and tags['ApplicationName'] !='Active Directory'and tags['ApplicationName'] != 'Clarity' #(lf)| project id, name, tags['ApplicationName'], tags, subscriptionId,resourceGroup)", null, null, null, [resultTruncated=null]),
Dummy = Table.FromRecords({ [id = "dummy", name = "dummy",resourceGroup ="dummy", subscriptionId = "dummy", tags = "dummy", ApplicationName = "dummy"] }),
result = if Table.IsEmpty(Source) then Dummy else Source
in
result
 
However Power Bi is still retuning a table with a single column and row.

adeelaziz_1-1709908970113.png

 

adeelaziz_0-1709908953403.png

 

I've spent an hour with Copilot, it had me try many things without success.  It finally concluded that the issue is with how ARG query handles the return of no results back to Power Bi.  Has anyone run into an issue like this with ARG queires in Power Bi or have any suggestions?
1 ACCEPTED SOLUTION
adeelaziz
Frequent Visitor

Finally managed to get around this issue, thank you Copilot for getting me two-thirds of the way there.  I also needed to add one of my actual subscription IDs as this table was linked to another using that column.

let
Source = AzureResourceGraph.Query("(resources #(lf)| where tags['ApplicationName'] != '3Par' and tags['ApplicationName'] !='Active Directory'and tags['ApplicationName'] != 'Clarity' #(lf)| project id, name, tags['ApplicationName'], tags, subscriptionId,resourceGroup)", null, null, null, [resultTruncated=null]),
DummyRow = [id = "No Results", name = "No Results", tags_ApplicationName = "No Results", tags = "No Results", subscriptionId = "{one of my subscription IDs}", resourceGroup = "No Results"],
Result = if Table.RowCount(Source) = 1 and Table.ColumnNames(Source){0} = "Results" and Source{0}[Results] = "No results" then
#table(Record.FieldNames(DummyRow), {Record.FieldValues(DummyRow)})
else
Source
in
Result

View solution in original post

1 REPLY 1
adeelaziz
Frequent Visitor

Finally managed to get around this issue, thank you Copilot for getting me two-thirds of the way there.  I also needed to add one of my actual subscription IDs as this table was linked to another using that column.

let
Source = AzureResourceGraph.Query("(resources #(lf)| where tags['ApplicationName'] != '3Par' and tags['ApplicationName'] !='Active Directory'and tags['ApplicationName'] != 'Clarity' #(lf)| project id, name, tags['ApplicationName'], tags, subscriptionId,resourceGroup)", null, null, null, [resultTruncated=null]),
DummyRow = [id = "No Results", name = "No Results", tags_ApplicationName = "No Results", tags = "No Results", subscriptionId = "{one of my subscription IDs}", resourceGroup = "No Results"],
Result = if Table.RowCount(Source) = 1 and Table.ColumnNames(Source){0} = "Results" and Source{0}[Results] = "No results" then
#table(Record.FieldNames(DummyRow), {Record.FieldValues(DummyRow)})
else
Source
in
Result

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors