Groups | Blog | Home
all groups > sql server reporting services > october 2006 >

sql server reporting services : showing column when it contains null


Brian L
10/6/2006 12:06:02 PM
I have a matrix that totals hits per person by month, 1-12. There are no hits
per month for the first 4 months of the year but my boss wants those columns
to show anyway. I pasted my query below. How is this done.

select name, rank, datepart(MM, date) , count(*)
from log
group by name, rank, date

the results show 4,5,6,7,8,9,10,11,12, but no 1,2,3 since no records.

Brian L
10/6/2006 12:20:01 PM
How do you code that?

[quoted text, click to view]
Brian L
10/6/2006 12:33:02 PM
Let me rephrase that. Since the value of the column is between 1 and 12, how
do you type the expression? =!Fields.Date.Value=1?

[quoted text, click to view]
Steve MunLeeuw
10/6/2006 1:11:40 PM
Can you do a cross join with a static list of columns?

Steve MunLeeuw


[quoted text, click to view]

Steve MunLeeuw
10/6/2006 1:59:19 PM
Ahh, sorry, should have been more precise, cross-join in the sql select
statement.

I use a table valued function with my static matrix column headers, then use
a CROSS JOIN to it

For example:

SET QUOTED_IDENTIFIER OFF

GO

SET ANSI_NULLS OFF

GO

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[fn_GetAssessmentSeries]') and xtype in (N'FN', N'IF',
N'TF'))

drop function [dbo].[fn_GetAssessmentSeries]

GO



CREATE FUNCTION fn_GetAssessmentSeries()

RETURNS @AssessmentSeries TABLE

(

SeriesName varchar(250),

SeriesSort int,

ChartSort int,

FilterFromChart int,

stType varchar(100)

)AS

/******************************************************************************

** File:

** Name: fn_GetAssessmentSeries

** Desc: Creates a table of series values. Not all series contain data,
cross joining

** to this table allows us to create matrix queries with no missing columns.

**

** Parameters:

** Input Output

** ---------- -----------

**

** Change History

*******************************************************************************

** Author: Date: Description:

** -------- -------- -------------------------------------------

** Steve MunLeeuw07/06/2006 Created for Assessment reports

*******************************************************************************/

BEGIN

INSERT INTO @AssessmentSeries

SELECT 'Students Tested', 0, null, 0, 'Count'

UNION SELECT 'Percent Tested', 1, null, 0, 'Percent'

UNION SELECT 'Mean Scaled Score', 2, null, 0, 'Score'

UNION SELECT 'Far Below Basic', 3, 2, 1, 'Percent'

UNION SELECT 'Below Basic', 4, 1, 1, 'Percent'

UNION SELECT 'Basic', 5, 0, 1, 'Percent'

UNION SELECT 'Proficient', 6, 3, 1, 'Percent'

UNION SELECT 'Advanced', 7, 4, 1, 'Percent'

UNION SELECT 'Below Proficient', 8, null, 0, 'Percent'

UNION SELECT 'At or above Proficient', 9, null, 0, 'Percent'



RETURN

END

GO

SET QUOTED_IDENTIFIER OFF

GO

SET ANSI_NULLS ON

GO


Here's part of my select clause:
Stat.SeriesName,

Stat.SeriesName,

Stat.SeriesSort,

Stat.ChartSort,

Stat.FilterFromChart,

Stat.stType

FROM

vw_rpt_Assessments v

INNER JOIN StudentGroupSet sgs

ON v.StudentGroupSetID = sgs.studentGroupSetID

INNER JOIN Assessment a

ON v.AssessmentID = a.AssessmentId

INNER JOIN GradeLevel gl

ON v.GradeLevelID = gl.GradeLevelID

CROSS JOIN fn_GetAssessmentSeries() AS Stat



[quoted text, click to view]

David Bienstock
10/16/2006 10:42:02 AM
Did you understand the cross join suggestion? It's a way to add columns that
will always show up. Also the "union" command is a way to add data to a
query as well.
--
"Everyone knows something you don't know"


[quoted text, click to view]
David Bienstock
10/16/2006 10:42:02 AM
Did you understand the cross join suggestion? It's a way to add columns that
will always show up. Also the "union" command is a way to add data to a
query as well.
--
"Everyone knows something you don't know"


[quoted text, click to view]
Brian L
10/24/2006 8:06:03 AM
no, this appears to be over my head.

[quoted text, click to view]
Steve MunLeeuw
10/24/2006 9:56:23 AM
Sorry about that, I'll try to write back later today.

Steve MunLeeuw

[quoted text, click to view]

AddThis Social Bookmark Button