How can I make two queries and divide the results within Report Builder?
![]()
Hubert Zenner (11●1)
| asked Nov 28 '18, 3:55 p.m.
edited Nov 29 '18, 3:10 a.m. by Ralph Schoon (62.7k●3●36●43) Hello,
Here an example:
![]() in a standard MS SQL Server 2014 express installation the following SQL code calculates the normalized defect density for a single value over a dummy database 'dbo.workitem' correctly: Declare @numerator int; Declare @denominator int; Declare @trend int;
Set @numerator = ( Select (SUM (CASE WHEN severity = 'Low' THEN 1 ELSE 0 END) + 2 * SUM (CASE WHEN severity = 'High' THEN 1 ELSE 0 END)) release From dbo.workitem WHERE Type = 'defect' AND release = 'Release 1.1');
Set @denominator = ( Select Count(type) From dbo.workitem WHERE Type = 'CR' AND release = 'Release 1.1');
if @denominator > 0 set @trend = @numerator / @denominator; select convert (varchar(10), @trend); The @numerator part works fine in the Report Builder as documented in the screenshot. But I did not manage to get the @denominator into the report. I tried with variable declarations in advanced mode but only got error messages on it. The same happens when I try to do the division in the select itself. I tried the calculation possibilities in the table formatting area without success as I was not able to select a second type for the filter on 'CR' Could anybody please help me and send tipps and tricks for Report Builder to do this different filtering (select on type 'defect' for numerator and type 'CR' for denominator and calculation of the division of both in the tool? any kind of link to similar examples would be also fine. If there is a better way to do this analysis please let me know. I would be very happy to learn more about the Report Builder functionalities available to resolve such analysis tasks. many thanks in advance for all your help! best regards Hubert |
Comments
Here is link to multiple Y-axis in case it can help in this case https://jazz.net/pub/new-noteworthy/jrs/6.0.6/6.0.6/index.html#3.
The result should be a single axis chart with the normalized weighted defect count. Normalized means that the number of defects (weighted) is divided by the overall number of changes in the same release.
Here what he wants to achieve: