Forum Discussion

PowerBINewbie7's avatar
PowerBINewbie7
New Member
2 years ago
Solved

Extracting substrings: FIND throwing error despite being skipped by IF Statement

Hi all!   I'm trying to extract a column containing information (in this example: the numbers) from a column which looks something like this:   INFORMATION01 INFORMATION02 ABCDEFG Info: ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi PowerBINewbie7 ,

    You can update the formula of calculated column as below:

    Column = 
    VAR _information =
        SEARCH ( "INFORMATION", 'Table'[Text], 1, 0 )
    VAR _info =
        SEARCH ( "Info: ", 'Table'[Text], 1, 0 )
    VAR _info1 =
        SEARCH ( "Ifo: ", 'Table'[Text], 1, 0 )
    RETURN
        SWITCH (
            TRUE (),
            _information > 0, RIGHT ( 'Table'[Text], 2 ),
            _info > 0, MID ( 'Table'[Text], VALUE ( _info ) + 6, 2 ),
            _info1 > 1, MID ( 'Table'[Text], VALUE ( _info1 ) + 5, 2 ),
            "Info not found"
        )

    Best Regards