简体   繁体   English

SSRS Distinct LookupSet 问题

[英]SSRS Distinct LookupSet Issue

I apologize for the long post but I'm losing my mind here.我为这篇长篇文章道歉,但我在这里失去了理智。 I've tried looking this up but I keep getting error messages on any suggested fixes on this thread:我已尝试查找此内容,但我不断收到有关此线程上任何建议修复的错误消息:

SSRS distinct lookupset function SSRS 不同的查找集 function

I've even tried to completely recreate a similar data set in that question but keep getting issues.我什至尝试在该问题中完全重新创建类似的数据集,但不断遇到问题。

s

This is the data set I created.这是我创建的数据集。

Using this in the expression box, and grouping by itemID, rackID, UseByDate在表达式框中使用它,并按 itemID、rackID、UseByDate 分组

Join(LookupSet(Fields!itemId.Value & Fields!UseByDate.Value & Fields!rackId.Value
, Fields!itemId.Value & Fields!UseByDate.Value & Fields!rackId.Value
, Fields!CustomerSeqNo.Value
, "PickingList"), ",")

I get我明白了

在此处输入图像描述

but I would like to remove the duplicates in the LookupSet so it would just display "1".但我想删除 LookupSet 中的重复项,以便它只显示“1”。

I tried the first 2 options in that link above but they both provided an error message:我尝试了上面那个链接中的前 2 个选项,但它们都提供了一条错误消息:

Public Shared Function RemoveDuplicates(m_Array As Object()) As String()

System.Array.Sort(m_Array)
Dim k As Integer = 0
For i As Integer = 0 To m_Array.Length - 1
    If i > 0 AndAlso m_Array(i).Equals(m_Array(i - 1)) Then
        Continue For
    End If
    m_Array(k) = m_Array(i)
    k += 1
Next

Dim unique As [String]() = New [String](k - 1) {}

System.Array.Copy(m_Array, 0, unique, 0, k)

Return unique

End Function

with this expression:用这个表达式:

=Join(Code.RemoveDuplicates(LookupSet(Fields!itemId.Value & Fields!UseByDate.Value & Fields!rackId.Value
, Fields!itemId.Value & Fields!UseByDate.Value & Fields!rackId.Value
, Fields!CustomerSeqNo.Value
, "PickingList")), ",")

returns this warning:返回此警告:

[rsRuntimeErrorInExpression] The Value expression for the textrun 'CustomerSeqNo.Paragraphs[0].TextRuns[0]' contains an error: Operator '&' is not defined for type 'Integer' and type 'CalculatedFieldWrapperImpl'. [rsRuntimeErrorInExpression] 文本运行“CustomerSeqNo.Paragraphs[0].TextRuns[0]”的值表达式包含错误:未为“Integer”类型和“CalculatedFieldWrapperImpl”类型定义运算符“&”。 and this error这个错误

在此处输入图像描述

The other solution doesn't even deploy.另一个解决方案甚至没有部署。 Any help here?这里有什么帮助吗?

Luckily for you @JMG, I just had to do this for a customer! @JMG 对你来说很幸运,我只需要为客户做这件事!

Here's the function:这是 function:

public function DistinctValues(input() as Object) as string
    dim newList as String

    for each n as string in input
       if InStr(newList, cstr(n) + ", ") = false
           newList += cstr(n) + ", "
       end if
    next

    return left(newList, len(newList) -2)
end function

So what it's doing is parsing through each value in the array.所以它所做的是解析数组中的每个值。 We are going to insert each unique value into a comma delimited string.我们将把每个唯一值插入到逗号分隔的字符串中。 Before doing so, we just check the string with InStr to see if that value already exists.在此之前,我们只需使用 InStr 检查字符串以查看该值是否已存在。

Make sure you cast the return value to string via CSTR(Fields.CustomerSeqNo.Value) to avoid any datatype issues.确保通过 CSTR(Fields.CustomerSeqNo.Value) 将返回值转换为字符串以避免任何数据类型问题。 Your code should look something like this.您的代码应该看起来像这样。

Code.DistinctValues(LookupSet(Fields!itemId.Value & Fields!UseByDate.Value & Fields!rackId.Value, Fields!itemId.Value & Fields!UseByDate.Value & Fields!rackId.Value, CSTR(Fields!CustomerSeqNo.Value), "PickingList"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM