Which version of Connect are you using? To be more precise do you know if your table is created with the latest dynamic table implementation? This can be viewed in the source of the section, the table in that case will have the data-expander=“2019” attribute.
I suggest to change the scope of the script. To do this: open the Options section at the bottom of the Edit Script dialog and change the scope to Each matched element. This exposes the “this” object for your script which provides access to the record used to generate this dynamic row.
The following script iterates over the table cells with .SalesQty class. The script evaluates the data used for this field and sets the background color of the cell when the value is larger than 2.
Selector: .SalesQty
var qty = this.record.fields.Quantity;
if ( qty > 2 ) {
this.css('background-color','#c0c0c0');
}