简体   繁体   中英

SSRS if field value in list

I've looked through a number of tutorials and asks, and haven't found a working solution to my problem.

Suppose my dataset has two columns: sort_order and field_value . sort_order is an integer and field_value is a numerical (10,2).

I want to format some rows as #,#0 and others as #,#0.00 .

Normally I would just do

iif( fields!sort_order.value = 1 or fields!sort_order.value = 23 or .....

unfortunately, the list is fairly long.

I'd like to do the equivalent of if fields!sort_order.value in (1,2,21,63,78,...) then...)

As recommended in another post, I tried the following (if sort in list, then just output a 0, else a 1. this is just to test the functionality of the IN operator):

=iif( fields!sort_order.Value IN split("1,2,3,4,5,6,8,10,11,15,16,17,18,19,20,21,26,30,31,33,34,36,37,38,41,42,44,45,46,49,50,52,53,54,57,58,59,62,63,64,67,68,70,71,75,76,77,80,81,82,92,98,99,113,115,116,120,122,123,127,130,134,136,137,143,144,146,147,148,149,154,155,156,157,162,163,164,165,170,171,172,173,183,184,185,186,192,193,194,195,201,202,203,204,210,211,212,213,263",","),0,1)

However, it doesn't look like the SSRS expression editor wants to accept the "IN" operator. Which is strange, because all the examples I've found that solve this problem use the IN operator.

Any advice?

Try using IndexOf function:

=IIF(Array.IndexOf(split("1,2,3,4,...",","),fields!sort_order.Value)>-1,0,1)

Note all values must be inside quotations.

Consider the recommendation of @Jakub, I recommend this solution if your are feeding your report via SP and you can't touch it.

Let me know if this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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