问题描述
我正在尝试创建一个 SSRS 报告,其中有一个表格来列出从查询中提取的一些数据.SSRS 中的当前表如下所示:
I am trying to create a SSRS report which has a table to list some data pulled from a query. The current table in SSRS looks like this:
LAST NAME FIRST NAME TITLE START END
morrow diane pcp 12/15/2009 1/15/2011
morrow diane pcp 5/15/2011 6/12/2013
morrow diane pcp 7/9/2013 12/11/2014
doe jane obgyn 10/12/2013 9/12/2014
ainswor michael opt 3/14/2008 4/23/2011
ainswor michael opt 6/6/2012 9/2/2014
我的 SQL 查询只是获取每条记录并将其添加为一行.
My SQL query just gets each record and adds it as a row.
我想做的是,在我的 SSRS 表中,我想使用一个函数并根据每条记录出现的次数扩展 START 和 END 列,例如,我想修改我的 SSRS表格显示如下:
What I am looking to do is, in my SSRS table, I would like to use a function and expand the START and END column based on how many times each record appears, so for example, I would like to modify my SSRS table to display like the following:
LAST NAME FIRST NAME TITLE START END START END START END
morrow diane pcp 12/15/2009 1/15/2011 5/15/2011 6/12/2013 7/9/2013 12/11/2014
doe jane obgyn 10/12/2013 9/12/2014
ainswor michael opt 3/14/2008 4/23/2011 6/6/2012 9/2/2014
这在 SSRS 中可能吗?还是我必须修改 SQL 查询?
Is that possible in SSRS? Or do I have to modify the SQL query?
更新:
到目前为止我在我的矩阵中有什么:
What I have so far in my Matrix:
输出是这样的:
对于最后一个实体,有两个条目:
For the last entity there are two entries:
DateOfLastCredentialing CredentialingExpiration
2007-12-24 2010-12-23
2013-10-14 2014-04-24
但是正如你所看到的,它只显示了一个.
But as you can see it is only showing one.
如何修复它以显示每个实体的两个或多个?
How do I fix it so it shows both or as many each entity has?
推荐答案
您可以使用 Matrix(一种 Tablix)来完成 SSRS 中的动态列,但您可能需要修改您的查询以便您有一个方便的字段来创建您的列分组.如果您之前从未在 SSRS 中创建过矩阵,您可以考虑使用向导(Visual Studio 项目 = 添加新报告,报告生成器 = 插入表向导),并将开始/结束日期分组字段放入列组中,以及行组中需要的任何其他字段.查看向导创建的表格以了解列分组的行为方式.
You can accomplish the dynamic columns in SSRS by using a Matrix (a type of Tablix), though you may need to modify your query so that you have a convenient field to create your column grouping on. If you've never created a matrix in SSRS before, you might consider using the wizard (Visual Studio Project = Add New Report, Report Builder = Insert Table Wizard), and putting your start/end date grouping field into the Column groups, and whatever other fields you need into the row groups. Take a look at the table that the wizard creates to get an understanding of how the column grouping behaves.
这篇关于如何根据条件在 SSRS 表中添加列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!