0

need to pass one column in Lookupset and I am doing as below

="Billing Code: "+Code.JoinDistinct(LookupSet(Fields!BillingCode.Value, Fields!BillingCode.Value, Fields!BillingCode.Value, "DataSet1"),",")

and the Function is

public shared function JoinDistinct(
  dups as object(),
  delimiter as string
) as string

  dim result as string = ""
  system.array.sort(dups)

  for i as integer = 0 to dups.length - 1
    if i <> 0 then result += delimiter
    if i = 0 orElse dups(i) <> dups(i-1) then result += dups(i)
  next i

  return result

end function

Result

Billing Code: ,,,A,,,,,,

How Can I remove extra commas

raky
  • 41
  • 3

1 Answers1

0

What you're trying to do is certainly possible, but requires a bit of a workaround. The Join function is designed to work on an array of values. The column you used, even though it may have multiple rows at that scope, is not an array. You can use the LookupSet function to get the rows as an array and pass them into the Join function. If there may be duplicate values that you want to remove, you'll have to add custom code to handle that.

Here's an example of how to do that: https://stackoverflow.com/a/27141955/2033717

Let me know if this answers your question.

StevenWhite
  • 5,907
  • 3
  • 21
  • 46
  • Join(LookupSet(Fields!itemId.Value , "Dataset1"), ",") I am using above as lookupset given an error – raky Jun 05 '19 at 18:30
  • `LookupSet` takes 4 arguments, not 2. See the link I shared or the official documentation on it for more detail. – StevenWhite Jun 05 '19 at 20:51
  • Steven, Updated my question. please answer it when you have a moment – raky Jun 06 '19 at 14:20
  • The original question had to do with getting the `Join` and `LookupSet` functions working. And it looks like they are now. If this custom function "JoinDistinct" is producing unexpected results, that would be a different question. I'm not familiar with the syntax used there. You might be able to find some similar examples that work better for you. – StevenWhite Jun 12 '19 at 22:47