Forum Discussion
jvanmeter
8 years agoFrequent Visitor
Extracting First DN out of Distinguished Name
How Do I Extract the Text Found at the First DN= of the Distinguished Name? Here is a Distinguished Name: CN=Test,OU=Iowa,OU=Primary,DC=NA,DC=US,DC=COM CN=Test,OU=Primary,DC=NA,DC=US,DC=COM ...
- 8 years ago
OK, that means that some of your values don't have a DC= in them so you will want to use the "Not Found Value" parameter of FIND. https://msdn.microsoft.com/en-us/query-bi/dax/find-function-dax
So, something like:
Column = VAR myStart = FIND("DC=",[DN],,-99) VAR myEnd = IF(myStart=-99,-99,FIND("DC=",[DN],myStart+3,-99)) RETURN IF(myEnd=-99,BLANK(),MID([DN],myStart+3,myEnd-myStart-4))
Greg_Deckler
Community Champion
8 years agoOK, that means that some of your values don't have a DC= in them so you will want to use the "Not Found Value" parameter of FIND. https://msdn.microsoft.com/en-us/query-bi/dax/find-function-dax
So, something like:
Column =
VAR myStart = FIND("DC=",[DN],,-99)
VAR myEnd = IF(myStart=-99,-99,FIND("DC=",[DN],myStart+3,-99))
RETURN IF(myEnd=-99,BLANK(),MID([DN],myStart+3,myEnd-myStart-4))
jvanmeter
8 years agoFrequent Visitor
That works Perfectly. Thank you.