Forum Discussion

Migasuke's avatar
Migasuke
Memorable Member
2 years ago
Solved

Dynamic SUBSITUTE

HI, I am having an use case where I need to use SUBSTITUTE function. SUBSTITUTE should have dynamic occurance - which means, someties it changes 1st occurance , sometimes 2nd etc. Summarizing the...
  • AlexisOlson's avatar
    2 years ago

    I think you're just not handling the case when there are no occurrences. This works for me:

    Where

    Last Occurance = 
    VAR _text = SELECTEDVALUE ( 'table'[Text] )
    VAR _ToPath = SUBSTITUTE ( _text, "X", "|" )
    VAR _Result = PATHLENGTH ( _ToPath ) - 1
    RETURN
        _Result