Sort or Getting specific words that be included in specific value

Hello.

In a datatable, I want to get words that only be included in “0” value.

캡처

on that case, answers are “Banana”, “mandarine”

Here is more detail

  1. Pick values “0” matched word combinations.
    ex) apple banana grape, banana, apple grape, grape, apple mandarine
  2. in that combinations, Delete words that in other “not 0” cells.
    ex) apple(x) banana grape(x), banana, apple(x) grape(x), grape(x), apple(x) mandarine
    => banana, banana,mandarine
    => banana, mandarine (delete duplicated)

Is there Anyone can make a assign line of that?

Please explain more on logic which word to select, as in your example “Apple Banana grape”, “Banana”, “Apple grape” and “grape” have zero value but you select only “Banana” and “Mandarine”. Why not others ?

@hoseongwon

Please try this

String.Join(",",Dt.AsEnumerable.Where(function(x) x("Value").ToString.Equals("0")).Select(function(x) x("word combination").ToString))

Cheers

Hi @hoseongwon ,
Give a try to given below query,

dtData.AsEnumerable().Where(function(x) x(“word combination”).toString.Trim.Equals(“0”)).Select(Function (x) x(“Word combination”).FirstOrDefault

handling not found case

We do not use CoptToDataTable when we can expect also an empty filter result. In such case CopyToDataTable will throw an exception. FirstOrDefault will return null in the case no matching row was found.

Thanks,

Hello

  1. Pick values “0” matched word combinations.
    ex) apple banana grape, banana, apple grape, grape, apple mandarine

  2. in that combinations, Delete words that in other “not 0” cells.
    ex) apple(x) banana grape(x), banana, apple(x) grape(x), grape(x), apple(x) mandarine
    => banana, banana,mandarine
    => banana, mandarine (delete duplicated)

Here is more detail

Assign: 식 작업 형식 'VisualBasicValue`1’을(를) 실행하려면 컴파일해야 합니다. 워크플로가 컴파일되었는지 확인하십시오.

Here is error message…

Hello .
your line only shows value 0 cell as it is written.

@hoseongwon

Can you please elaborate on what you are looking for

Cheers

Hi @hoseongwon,

Please refer below blog for justification.

Hope this will work ,
Thanks,

Sad… Error solved.
but that did not work.

I added details on that. :slight_smile:

try the attached solution and let us know if you have any query.
Test.xaml (10.7 KB)

Hi @hoseongwon ,

Maybe another work around.

  1. Prepare the Splitted Datatable row data based on the word combination column. So that we will have individual words in each row of word combination as the operation also needs to be performed in the same way. We can use the below expression to perform it.
OutputDT = (From x In DT.AsEnumerable
Let splitData = Split(x("word combination").ToString).ToArray
From s In splitData
Select OutputDT.Rows.Add(s,x("value").ToString)).CopyToDataTable

Here, DT is the input Datatable variable and OutputDT is the clone of the Input datatable.

  1. Next, we can Perform Group By on word combination column and Filter based on the value column to select only those row groups where all the values are 0.
ZeroValueWords = OutputDT.AsEnumerable.GroupBy(Function(x)x("word combination").ToString.ToLower).Where(Function(x)x.All(Function(y)CInt(y("value").ToString)=0)).select(Function(x)x.First.Item("word combination").ToString).ToArray

Here, ZeroValueWords is an Array of String type variable.

Workflow Visual :

Debugging Visual :
image

1 Like

Omg Omg Omg!!
your solution was totally worked and explanation was also impressive.
So thankful .
If we are in same country, I would like buy some drink.
:slight_smile:
Thank you!!!

1 Like

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