Report via Automation Returns NULL unless "For Each Row In Table" is enabled

I have a report attachment that calls a column with this expression:
COUNT(UNIQUE(SELECT(
Inspections[StructureID],
AND([Schedule] = [_THISROW], MONTH([TimeStamp]) = 1)
)))

If I include this column in a view, the expected results are returned. I can download this view via Export to CSV and the expected data is present in this column.

If I run an automated report that includes a CSV or XLSX attachment, the column is blank. If I enable “For Each Row In Table”, the expected data is returned but, the report is sent for every row in the table on which the automation is run.

What is preventing the column from returning values unless the “For Each Row In Table” is enabled?

I have other columns which use similar expressions and they return the expected values without “For Each Row In Table” being enabled.

Any hints pointing in the direction of a resolution would be greatly appreciated.

In general, it should work. You seem to be selecting records for just January in the expression with MONTH([TimeStamp]=1. Hope you have ensured there are records for the month of January existing when testing the automation.

Also you may want to verify the following part of the expression [Schedule] = [_THISROW].
[_THISROW] represents a key so hope that part is correct. I mean [Schedule] value being compared to a key. Maybe you have a schedule table where key itself represents a schedule value, then this could be correct comparison.

In the opening statement of the original post, I mention that it works as expected in a view of the app and when exporting as a CSV. But does not work when generating a report from an automation.

Yes, for this instance, I only want records for January. And I am certain there are records for this month. See the original post where I mention that this works when viewing the data in the app and exporting a CSV.

Yes, [Schedule] is a foreign key in the Inspection table referencing the Schedule table.

Hi @MichaelN ,

Thank you for the revert.

I had tested it on a similar setup as yours before responding. A couple of VCs having expressions with SELECT() and [_THISROW] etc. and the values for those columns were populated properly in the XLSX report.

The test also included a START expression in the template and not running the bot on “Each row in the table.”

So wrote that “in general” it should work and mentioned to recheck other possibilities that appeared good candidates for a recheck from the details shared.