Forum Discussion
Anonymous
3 years agoNot applicable
Extract document number from a string using a list from another table as reference
Preferably as a DAX calculated column, I am looking for a way of extracting a document number from a string of text that exists in a column of one table whenever the starting values from a list that ...
- 3 years ago
Hi Anonymous ,
Pls adjust to the below:
Doc Number2 = VAR Table_ = MAXX ( FILTER ( Table2, SEARCH ( Table2[Column2], Table1[Column1],, 0 ) > 0 ), Table2[Column2] ) RETURN VAR Start_p = SEARCH ( Table_, Table1[Column1], 1 ) VAR End_p = IFERROR ( IFERROR ( IFERROR ( SEARCH ( ".", Table1[Column1], Start_p ), SEARCH ( " ", Table1[Column1], Start_p ) ), SEARCH ( ",", Table1[Column1], Start_p ) ), LEN ( Table1[Column1] ) + 1 ) VAR End_p2 = IFERROR ( IFERROR ( IFERROR ( SEARCH ( " ", Table1[Column1], Start_p ), SEARCH ( ".", Table1[Column1], Start_p ) ), SEARCH ( ",", Table1[Column1], Start_p ) ), LEN ( Table1[Column1] ) + 1 ) VAR End_p3 = IF ( End_p < End_p2, End_p, End_p2 ) RETURN IF ( Table_ <> BLANK (), MID ( Table1[Column1], Start_p, End_p3 - Start_p ), "" )Output result:
Best Regards
Lucien
Bifinity_75
3 years agoSolution Sage
Hi Anonymous !, for leaving the result in the new column blank, add this lines to the final of the calculate column:
IF(Table_<>BLANK(),
MID(Table1[Column],Start_p,End_p-Start_p),"")
If the formula does not work for you, you can send me the file privately.
I hope works for you!, best regards