Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
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
I want the output of the above to be NA
Essentially it would find the first occurnance from the left of DC= and return the text after that untill the next ,
This would give me the domain of each user.
Thank You Ahead of Time.
Solved! Go to Solution.
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))
Column = VAR myStart = FIND("DC=",[DN]) VAR myEnd = FIND("DC=",[DN],myStart+3) RETURN MID([DN],myStart+3,myEnd-myStart-4)
I get this error, "The search TExt Provided to function 'FIND' could not be found in the given text.
@Edit
It does not like FIND("DC=",[distinguishedName]) but does accept FIND("DC=",[distinguishedName],1,0) for whatever reason that is whats throwing the error
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))
That works Perfectly. Thank you.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
87 | |
83 | |
82 | |
65 | |
49 |
User | Count |
---|---|
135 | |
111 | |
100 | |
65 | |
62 |