Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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 problem:
Solved! Go to Solution.
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
@AlexisOlson Awesome solution. Thanks for that!
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
User | Count |
---|---|
84 | |
78 | |
70 | |
46 | |
42 |
User | Count |
---|---|
106 | |
50 | |
49 | |
40 | |
40 |