"Cannot find column [Income]."

csv
activities
studio

#1

Hello,

I have and CVS sample file:

In the tutorial he uses assign activity to be able to find whose income is greater than 40k.Because there is a letter after 40 he uses something which I could’t figure.

sampleData.Select(“Age<40 and Income>‘40k’”)

I can’t see what exactly he writes here so I guessed he uses apostrophe before k and after 0 and close it with ". However I am getting error and it says Assign : “Cannot find column [Income].” Anyone knows the correct syntax?

Thanks in advance!


#2

the syntax for the filter expression is like below

[<Column Name>] <Operator> <value>

You can have multiple Conditions combined together by using keywords like:

AND, OR

if the value in the expression is of a String Datatype then, it should be enclosed between single quotes

so your example is constructed like this:
Condition1:
Column name:Age
Operator:<
Value:40
Condition2:
Column name:Income
Operator:>
Value:**’**40k [Note that 40k is enclosed by on both sides]
Both these conditions are combined with AND

Also for your error, where it says Column Income isn’t found, You can you Output Datatable Activity to convert entire datatable to a string and use a writeline activity to actually see whether the datatable actually contains the column.


#3

Thank you for the answer. I am reading the datatable after this. However it doesn’t read because I am getting error at that line. As you can see here I am writing ‘40k’.

I added the file If you would like to check. My file is CSV.

.Main.xaml (6.9 KB)

Excel file


#4

25k for @badita, i think he needs a raise.

@kyre you workflow works fine for me.

Attached is my code for your reference
Main.zip (1.9 KB)


#5

Really? Are you using trial version?


#6

No, can you paste the screenshot of the error?


#7

It basically says this in the output " Assign : Cannot find column [Income]."


#8

I am using trial version which may not work as the actual one.


#9


#10

Can you check if there is any space in Income column in your csv file?


#11

There was a space!

I do appreciate Vvaidya:)


#12

hi @akhi_s27

Wanted to do below operation checking the variable text , as of now using many if activities , appreciate if any shorter suggestion to write conditions as below and check all in one go.

Final Variable text depends on conditions
If(Variable.text==”Delhi”)
{
Final_Variable = “New Delhi”
}
If(Variable.text==”Mum”)
{
Final_Variable = “Navi Mumbai”
}
Else
{
Final_Variable = “Others”
}


#13

Try with a switch activity.


#14

Best option here is to create a mapping here and use as your config.
Here even if you use switch statements, it’ll support only those hard coded values.
If in future you need to add support for a new location, you’ll have to add a new case inside the switch for getting the correct value for it rather than specifying others.

I usually make dictionaries out of my configuration files - Excel
so if i had used those here my code would be like,

if dictionary.ContainsKey(Variable.text) then
    Final_Variable = dictionary.Value(Variable.text)
else
    Final Variable = "Others"
End If

You could learn how to make use of dictionary variables very quickly online.
Creating a dictionary with required values is something you’ll feel tedious to do in the beginning, but believe me, it surely has many pros.

One other way to achieve this similar result is by using LINQ and by that way you’ll not have to convert all your excel configurations into dictionaries, simply having all those excel’s read into datatable and grouped into a Dataset will work wonders.