Forum Discussion
FIND and SUBSTITUTE
Good day Everyone,
I hope someone can shed a light to my issue as I am stuck. So I wanted to replicate a formula from Excel to PowerBI
the column for [All Involved] looks like this:
;group1;Triage;group2;Triage;group3;
The formula below works :
This one is where I am getting error :
hi Anonymous
There are two mistake in your Position formula
1.
SUBSTITUTE(<text>, <old_text>, <new_text>, <instance_num>)
For <instance_num>, it could not be 0, so you need to add a IF conditional in the formula
https://docs.microsoft.com/en-us/dax/substitute-function-dax
2.
FIND(<find_text>, <within_text>[, [<start_num>][, <NotFoundValue>]])
For FIND function, it will return the starting position of one text string within another text string, but if there is no result and you need to define a <NotFoundValue>
https://docs.microsoft.com/en-us/dax/find-function-dax
So adjust the formula as this
Position = IF([Count]>0, FIND(";;",SUBSTITUTE([All Involved],"Triage","",[Count]),1,0)+1)Regards,
Lin
2 Replies
- vanessafvg
Community Champion
can you explain what error you are getting, and what you are expecting? - v-lili6-msft
Community Support
hi Anonymous
There are two mistake in your Position formula
1.
SUBSTITUTE(<text>, <old_text>, <new_text>, <instance_num>)
For <instance_num>, it could not be 0, so you need to add a IF conditional in the formula
https://docs.microsoft.com/en-us/dax/substitute-function-dax
2.
FIND(<find_text>, <within_text>[, [<start_num>][, <NotFoundValue>]])
For FIND function, it will return the starting position of one text string within another text string, but if there is no result and you need to define a <NotFoundValue>
https://docs.microsoft.com/en-us/dax/find-function-dax
So adjust the formula as this
Position = IF([Count]>0, FIND(";;",SUBSTITUTE([All Involved],"Triage","",[Count]),1,0)+1)Regards,
Lin