Forum Discussion

phillip_from_oz's avatar
phillip_from_oz
Frequent Visitor
4 years ago
Solved

Active Directory useraccountcontrol bit mask decode function

Everyone, I’m working through AD useraccountcontrol integer conversion post: https://community.powerbi.com/t5/Desktop/AD-useraccountcontrol-integer-conversion/td-p/437105 There is this function (P...
  • v-jingzhang's avatar
    4 years ago

    Hi phillip_from_oz 

     

    In the custom function, input is expected to be of number type. If you don't want to keep non-numeric values in userAccountControl column, you can change this column into Decimal Number type. Blank values will become null and non-numeric values will become Error. Replace Errors with null.  

     

    Then when you add the custom function column, check whether the input value is null. When it's not null, invoke the custom function.  

    = Table.AddColumn(#"Replaced Errors", "UAC", each if [userAccountControl] = null then null else fnConvertUAC([userAccountControl], UACRef, "decimal", "|"))

     

    If you want to keep non-numeric values in userAccountControl column, you need to keep this column of Text type. Then extract decimal number to invoke custom function when you add the column. 

    = Table.AddColumn(#"Changed Type", "UAC", each let __number = Number.From([userAccountControl]) in if (try Value.Is(__number, type number) otherwise false) then fnConvertUAC(__number, UACRef, "decimal", "|") else null)

     

    Hope it helps!

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.