Handling Multiple matches as occurrences on a Table Index

Hello all,

I have the following table:

vehicle year selling_price km_driven fuel seller_type transmission owner mileage engine seats
Honda City 2017-2020 EXi 2006 158000 140000 Petrol Individual Manual Third Owner 17.7 kmpl 1497 CC 5
Toyota Etios VXD 2011 350000 90000 Diesel Individual Manual Second Owner 23.59 kmpl 1364 CC 5
Toyota Etios VXD 2011 340000 89000 Diesel Individual Manual First Owner 23.59 kmpl 1364 CC 5
Maruti Swift Dzire VDI 2014 450000 145500 Diesel Individual Manual First Owner 23.4 kmpl 1248 CC 5
Skoda Rapid 1.5 TDI Ambition 2014 370000 120000 Diesel Individual Manual Second Owner 21.14 kmpl 1498 CC 5
Hyundai i20 Sportz Diesel 2010 225000 127000 Diesel Individual Manual First Owner 23.0 kmpl 1396 CC 5
Maruti Swift VXI BSIII 2007 130000 120000 Petrol Individual Manual First Owner 16.1 kmpl 1298 CC 5

and using the ‘column expression’ node, within the following expression:

if (contains(column("vehicle"),variable("Toyota Etios VXD")) == true) {
    column("vehicle")
} else {
    (" ")
}

As you see, the output will be the first row where the result is first found:

|Toyota Etios VXD|2011|350000|90000|Diesel|Individual|Manual|First Owner|23.59 kmpl|1364 CC|5|

Later on, in my code I have to use all rows where the value ‘Toyota Etios VXD’ is found.

How can I request for the expression above analyze, for example, a +1 row (btw, they’re usually together, one after the other, but would like to handle it if they were not, just in case).
So, something like the following pseudocode, pardon me if isn’t clear, feel free to ask:

if(contains(column("vehicle"),variable("Toyota Etios VXD")) == true) {
    ALLROWS FROM column("vehicle") WHERE VALUE MATCHES variable("Toyota Etios VXD"))
} else {
    (" ")
}

where the result would return me both of these rows:

|Toyota Etios VXD|2011|350000|90000|Diesel|Individual|Manual|Second Owner|23.59 kmpl|1364 CC|5|
|Toyota Etios VXD|2011|340000|89000|Diesel|Individual|Manual|First Owner|23.59 kmpl|1364 CC|5|

Thank you,
J.

Hello @jarviscampbell
I think we’ve been dealing with a few wildcard filtering requests, in the latest days. Not by using Column Expressions node but regex match. We solved your latest topic in a similar way

You can have a look to the following topic (2 days ago) in forum for insights; as I think is very similar problem, but in your case using a complete row instead of a ‘description’

However in the example you show; Why not to use a standard Row Filter?
You may not need to complicate your workflow with logical indexing either. By filtering $vehicle$ == ‘Toyota Etios VXD’ you can achieve the desired output.

BR

3 Likes

Hi @jarviscampbell , @gonhaddock has already answered your question and I would do the same, which is using the Row Filter.

In addition, I wanted to clarify something for you. This:

if (contains(column("vehicle"),variable("Toyota Etios VXD")) == true) {
    column("vehicle")
}

The above expression will be applied to all the rows of column “vehicle”, not just 1 row. So from your sample data, both lines 2 and 3 will be true. You do not need to do a+1 row

3 Likes

Thanks @bruno29a ,

I understand that, however, when this expression only picks up the first occurrence of the variable. It does not return me ‘all’ occurrences, and that’s what I am after. Thanks!

J.

Hi @jarviscampbell , if that is the case, then it could be that your data might have some hidden characters or have space before or after the value, which you can’t see with the eyes.

One trick to test this is to do something like via String Manipulation:
join("XXX", $vehicle$, "XXX")

This will show you if there are any spaces before or after the values in your vehicle column.

Also, what is in your variable “Toyota Etios VXD”?

1 Like

Sorry, I get it confused. It should have been:

if (contains(column("vehicle"),variable("cars")) == true) {
    column("vehicle")
}

I have a ‘Single Selection Configuration’ Node with a few selection of cars. One of them is the ‘Toyota Etios VXD’, so when I select it, it becomes a ‘variable’ value. Sorry about the confusion. I was able to figure it out and make it work with the ‘Find Keyword’ workflow.

Thanks again,
J.

All good @jarviscampbell , glad you figured it out :smiley:

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