Forum Discussion

Johannes_W's avatar
Johannes_W
Regular Visitor
5 years ago

CONTAINSSTRING checking multiple inputs

Dear all,

 

I have a situation I am sure should be possible to resolve, but I can not crack it.

 

I have several unique processes (A, B, C, D .. ) that have error_ids associated to them, some only a few, some hundreds

 

Table1

Process_id error_ids
Atree
Aapple
Amouse
Btree
Bhorse
Cdesk
Ctiger
Dtree
Dmouse
Dhorse
Dtiger

 

 

All these processes also have messages associated to them, again, some only a few, others up to a hundred.

Only this time, the messages are convoluted strings.

 

Table2

Process_id event_message 
Atree mouse sequenze
Aapple pie
Asome text
Bsome more
Cdesktop
Cmouse soup
Dtree house
Dmouse house
Dwooden desk

 

 

I am trying to create a calculated col that gives me true/false if ANY of the error codes that belong to a process appears in the event_message. Or in other words, 'go through the evene messages one by one and check if any of the error codes of the corresponding process appears in the the message'

 

The expected result would be:

 

Table2 - with new col

Process_id event_message error found?
Atree mouse sequenceTrue
Aapple pieTrue
Asome textFalse
Bsome moreFalse
CdesktopTrue
Cmouse soupFalse
Dtree houseTrue
Dmouse houseTrue
Dwooden deskFalse

 

I have a solution for a SINGLE error code (like 'tree')

 

 

 

error_found? =  
VAR get_error = 
CALCULATE(  
FIRSTNONBLANK( 
Table1[error_ids],1), filter( ALL(Table1), Table1[error_ids] = 'tree' && 'Table2'[Process_ID] = 'Table1'[Process_ID])) 
RETURN 
CONTAINSSTRING('Table2'[even_message], get_error ))

 

 

 

but that is of limited use to me. I also can not predict how many error codes a process could have. So I need to find a solution that turns a column of error codes over to COINTAINSSTRING, somehow.

 

I apprechiate all your help!

Thanks

Joh

2 Replies

  • Johannes_W , Try like

     

    new column =
    var _cnt = countx(filter(Table1, search(Table1[error_ids], Table2[event_message],,0)>0 && Table1[Process_id] = table2[Process_id]), Table1[Process_id])
    return
    if(not(isblank(_cnt)), True(), false())

    • Johannes_W's avatar
      Johannes_W
      Regular Visitor

      Hi! Thanks for this suggestion, but it returns FALSE for me for every row which can not be true.