Hello, I want to count failed reports in DB, it means where outcome value of report is "Failed". declare namespace TestResults='urn:IEEE-1671:2009.04:TestResults'; declare namespace Common='urn:IEEE-1671:2010:Common'; let $DocumentNames := (db:list("ASC", "Report")) for $DocumentName in $DocumentNames let $Document := db:open('ASC',$DocumentName) let $FailedTests := $Document/TestResults:TestResults/TestResults:ResultSet/ TestResults:TestGroup/TestResults:TestGroup/TestResults:TestGroup/ TestResults:TestGroup/TestResults:Test/TestResults:Outcome/data(@value) where $FailedTests="Failed" return count($FailedTests) However, it counts all reports, no matter if the value is "Passed" or "Failed". If I change the end to: return $FailedTests, it displays both "Failed" and "Passed" values. If I change it to: where $FailedTests="Test", it displays correctly 0 reports. What am I doing wrong? Thank you in advance for your reply. Radim Havlicek