Skip to content
Advertisement

Group-by and coalesce cannot be combined, gives an error?

I am creating an SSRS report and while making the data queries to it I got into this error. I do need the data set (Month to Date and Year to Date values) in one row connected with a group by command. This is the crystal report I’m referring to and converting to SSRS.

The error I get is something like : Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

Note: I cannot use 2 sub queries such as one for MTD and one for YTD values since values does not match with the row description. That is the whole reason I’m trying to use some coalesce functions with individual group-by commands.

What I have tried :

The issue is with the individual group-by commands following with the coalesce I feel like, because without those the query works but only returns the same total sum value for all the rows. Reference

Here is a sample dataset for reference :

Advertisement

Answer

The solution is to use UNION with a “zeroed” row and add an aggregate :

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement