Contains with Lowercase

Solved!
imransaiful17
Level 2
Contains with Lowercase

Hi Team,

I have a dataset which one column consisting of multiple values, for example

Column1
Metric1,Country
METRIC1,Country
METRIC1,Country
Metric2,Country

Is there a work around to filter the values in the column to only keep the value that contains 'Metric1' regardless of the case.

The result should be:

Column1
Metric1,Country
METRIC1,Country
METRIC1,Country

I tried the below query but it does not work.
( contains(toLowercase(val('Column1')), toLowercase(val('METRIC1'))) )

Please assist.

0 Kudos
1 Solution
MarcH
Dataiker

Hello, I think you have an extra "val" in your formula. Can you please try:

 

contains(toLowercase(val('Column1')), 'metric1')

 

 

View solution in original post

4 Replies
Manuel
Dataiker Alumni

Hi,

In a Prepare recipe you can use the "Extract with Regular Expression" processor, which will allow you to identify the rows that contain Metric1 in either lowercase or uppercase.

https://doc.dataiku.com/dss/latest/preparation/processors/pattern-extract.html

To help you with the regex expression, use the smart pattern builder and select the right values

https://knowledge.dataiku.com/latest/courses/advanced-data-prep/prepare-recipe/smart-pattern-builder...

I hope this helps.

Best regards

MarcH
Dataiker

Hello, I think you have an extra "val" in your formula. Can you please try:

 

contains(toLowercase(val('Column1')), 'metric1')

 

 

imransaiful17
Level 2
Author

Hi MarcH,

This solution works for me !  Thanks! Additionally can you help to elaborate further what does the val() function really represents here? Cause if i tried to remove the val() function, it does not work.

contains(toLowercase(val('Column1')), 'metric1')

 

0 Kudos
MarcH
Dataiker

Hello, good to hear! The val() function returns the value of the column whose name you give as an argument (the column named 'Column1' in your example). If you just put 'Column1' without the val(), you'll just get a String that always has a value of 'Column1', like was done for 'metric1' in your example.

0 Kudos