Datatable.Select("Zodiac = 'Leo'") does not work properly when getting the zodiacSign from user

Hello guys,

I created a sequence that creates a datatable and filling it with information about random generated people (name, phone number, location, job position and zodiac sign).

After the DataTable is created i would like to output data while filtering them as per zodiac sign.
For that reason i assign a new variable “FilteredData” using DataTable.Select() function.

It works perfectly fine if i use a specified zodiac sign e.g “Leo” as you can see in the photo below:

However i tried to make an extra step and make the user select the zodiac sign he wants to output using and InputDialog activity and storing the user’s selection in a new variable (selectedZodiac).

I can’t assign the users option in the FilteredData variable as i did before in order to output the people with the “selected” zodiac sign
(i have tried a lot of things like
ExtractDataTable.Select(“Zodiac = ‘selectedZodiac’”)) ,
ExtractDataTable.Select(“Zodiac = selectedZodiac”) ,
ExtractDataTable.Select(“Zodiac” +selectedZodiac) ,
ExtractDataTable.Select(“Zodiac” == selectedZodiac) ,
etc

The main problem is that i cant “transfer” the value of the selectedZodiac variable in the FilteredData using the .Select function.

Thank you in advance

Hi @gorge200

ExtractDataTable.Select(""“Zodiac = '” & selectedZodiac & “’”""))

1 Like

Hi @gorge200,
Welcome to the UiPath community forum!
Try using it as below.

ExtractDataTable.Select("[Zodiac]=’ “+yourZodiacValue+” ’ ").CopyToDataTable

Hope this will work for you.
Thanks.

Hi to make this more secure to ensure that a use will only enter the correct zodiac sign, use an array as your options

e.g.
{“Aries”,“Taurus”,…}

This will present a dropdown list to the user :slight_smile:

Then use as others have suggested.
Depending on which version you are using - you can use the filter datatable activity also.

1 Like

Hey @gorge200

Try this

ExtractDataTable.Select(“Zodiac = ‘{{selectedZodiac}}’”)

1 Like

Update: Solved : your answers work !!! i also checked this one and it works appropriately : ExtractDataTable.Select(“Zodiac= '”+selectedZodiac+"’")

There is no reason to copy it back to the DataTable in this one but with the way u suggested i am not loosing the information.
Thank you for your time !

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.