Search code examples
sqlreporting-services

sql (reporting services) field split and find


I have a field, which contains an address with comma separations like: always some code and then description

"19415 - City" (different city has a different code)
"ABTH - sites" (always 4 digits and have a "TH" in the end, only the first 2 letters change)
"ABCD - building" (always 4 different letters)
and more place describing data, but those are not required

in the query I can split into 3 columns with

=fields!A_hiba_helye.Value.split(",")(0) and in the column I change the (0) to (1) or (2)

but the input is mixed up in some cases

thanks


Solution

  • managed to solve the problem. for the cities i used InStr just like above, and for the sites and buildings i used iifs: sor the sites:

    =iif(fields!A_hiba_helye.Value.split(",")(0).contains("TH"), fields!A_hiba_helye.Value.split(",")(0),
    (iif(fields!A_hiba_helye.Value.split(",")(1).contains("TH"), fields!A_hiba_helye.Value.split(",")(1), fields!A_hiba_helye.Value.split(",")(2) )) )
    

    and for the buildings:

    =iif(fields!A_hiba_helye.Value.split(",")(0).contains("TH") Or (fields!A_hiba_helye.Value.split(",")(1).contains("TH")),
    fields!A_hiba_helye.Value.split(",")(2),
    (iif(fields!A_hiba_helye.Value.split(",")(1).contains("TH"), fields!A_hiba_helye.Value.split(",")(2), fields!A_hiba_helye.Value.split(",")(1) )) )