Switch is greater than 1

Hi all,

Is there anyway to use a switch and switch on the following integer amounts -

‘0’
‘1’
‘> 1’

Or am i going to have to use lots of If activity’s?

Thanks,

Hi @Alexander_Ward,

You can check this topic. It should helps.

Regards
Ömer

If(DT.RowCount=0,0,If(DT.RowCount=1,1,2))

Hi @Alexander_Ward ,

Could you let us know what are the different values/cases that you would be receiving ?

I do a search for a property in our CRM system and extract the results into a datatable.

If the datatable is = 0 then I exception as the property does not exist.
If the datatable is = 1 we have found the property.
If the datatable is > 1 then i need to do more validation for example add the property’s tenant surname until we only find one result. If i still find more than 1 then it’s a business exception.

Thanks for the response.

This could be more than two so would it only be searching for the number ‘2’?

if… rowcount=0 means output is 0
if… rowcount=1 means output is 1
if rowcount>1 means output is 2

So i would use the case of 2 for anything that has been greater 1?

Yes…Try it and let me know if u get any bug.

Hi @Alexander_Ward ,

try like below. just sharing suggestion. but as mentioned by other members we could easily implement this with if conditions. thanks.

use the following expression if((dt.rows.count>1),“greaterthanone”,if((dt.rows.count=0),“equaltozero”,if((dt.rows.count=1),“equaltoone”,if((dt.rows.count<1),“otherscenario”,“Default”))))

in the above expression greaterthaanone, equaltozero and equaltoone are the cases. inside of the cases we can built our validation logics.

type argument property in the switch case set to string.

Regards,
Kirankumar.

That’s what the Default is for. It’s what executes if none of the other Cases match. So put your “>1” code into the Default block.

However, it’s usually best to use Else If for this kind of thing. Switch isn’t designed to be used like this, and future modifications could be a problem if you need more variation than just your example here.

Hi @Alexander_Ward ,

In default you can place an IF activity with condition dt_locationSearchResults.Rows.Count>1 and here do what you want.