如何将不同的值放在相同的参数标签下

发布于 2025-01-23 04:54:13 字数 901 浏览 3 评论 0原文

我的表看起来与下面选择不同的示例相似。该格式是MainFolder-SubFolder1-SubFolder2

文件夹
A
A-B
A-BC
BC
BDE,

我想创建一个下拉参数,其中选项将为A或B。如果我选​​择A,则表将显示A,AB和ABC。理想情况下,我想创建多个参数,以便用户能够选择他们想要查看的主要文件夹以及子文件夹。

我尝试使用以下查询创建数据集 选择不同的文件夹,当文件夹之类的文件夹之类的文件夹时,例如“ b%”之类的文件夹,然后'b'end作为mainFolder,它为下面的表提供了下面的文件

mainfolder
a aa a
a a-ba
-a- BCA
B-CB
B-DEB

I然后创建一个参数,其中可用值来自数据集。值字段是文件夹,标签字段是主基础。我想要它,以便当我运行报告时,参数仅显示A或B,但是表将显示完整的文件夹详细信息。但是,我从下拉参数中得到的是a,a,a,b,B。

I have a table that looks similar to the example below when selecting distinct. The format is MainFolder-SubFolder1-SubFolder2

Folder
A
A-B
A-B-C
B-C
B-D-E

I want to create a drop down parameter where the options would be A or B. If I select A, then the table will show A, A-B, and A-B-C. Ideally I would like to create multiple parameter so users are able to select what main folder they want to look at as well as the subfolders.

I have tried creating a dataset with the following query
SELECT DISTINCT Folder, CASE WHEN Folder LIKE 'A%' THEN 'A' WHEN Folder LIKE 'B%' THEN 'B' END AS MainFolder Which gives the table below

FolderMainFolder
AA
A-BA
A-B-CA
B-CB
B-D-EB

I then create a parameter where the available values are from the dataset. The value field is Folder and label field is MainFolder. I want it so that when I run the report the parameter only shows A or B, but the table will show the full folder details. However what I get from the drop down parameter is A, A, A, B, B.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桜花祭 2025-01-30 04:54:13

我不确定我是否完全了解您的问题,但是您不仅可以为看起来像这样的参数值创建数据集。

SELECT DISTINCT LEFT(Folder, 1) AS MainFolder FROM myTable

然后,您的主数据集查询将是...

SELECT * FROM myTable WHERE Left(Folder,1) = @pMainFolder

...代码>是您的参数的名称

,或者如果PMAinFolder是多价值,则可以

SELECT * FROM myTable WHERE Left(Folder,1) IN(@pMainFolder)

在OP之后进行**更新**。

假设所有文件夹都有某种形式的定界符(示例中的-),则可以

Left(Folder,1)

对其

LEFT(Folder, CHARINDEX('-', Folder)-1)

在我发布的前示例中

进行替换。 Charindex在文件夹列中为我们提供了第一个-的位置。因此,在“ admin-south”中,这将是位置6,然后我们减去1给我们5 “

I'm not sure I fully understand your issue but can you not just create dataset for the parameter values that look something like this..

SELECT DISTINCT LEFT(Folder, 1) AS MainFolder FROM myTable

Then you main dataset query would be something like ...

SELECT * FROM myTable WHERE Left(Folder,1) = @pMainFolder

... where pMainFolder is the name of your parameter

or if pMainFolder was multi-values you could do

SELECT * FROM myTable WHERE Left(Folder,1) IN(@pMainFolder)

**UPDATE ** after OP additional info.

Assuming all the folders have some form of delimiter (the - in your example) you can substitute this

Left(Folder,1)

with

LEFT(Folder, CHARINDEX('-', Folder)-1)

in the previous examples I posted.

CharIndex gives us the position of the first - in the Folder column. So in "Admin-south" this would be position 6, we then subtract 1 giving us 5 and use that in the LEFT function so we only get back the first 5 leftmost characters, in this example "Admin"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文