+ Reply to Thread
Results 1 to 8 of 8

Sort Active Directory users by group

Hybrid View

  1. #1
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Sort Active Directory users by group

    You could do something like:

    Use Power Query to import your CSV data, and index by Group:

    let
        Source = Csv.Document(File.Contents("C:\temp\powershell.csv"),[Delimiter=",", QuoteStyle=QuoteStyle.Csv]),
        #"Extracted Text Between Delimiters" = Table.TransformColumns(Source, {{"Column2", each Text.BetweenDelimiters(_, """", """"), type text}}),
        #"Promoted Headers" = Table.PromoteHeaders(#"Extracted Text Between Delimiters", [PromoteAllScalars=true]),
        #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Group", type text}, {"member", type text}, {" enabled", type logical}}),
        #"Index Partitions" = Table.Group(#"Changed Type", {"Group"}, {{"Partition", each Table.AddIndexColumn(_,"Index",1,1), type table}}),
        #"Expanded Partition" = Table.ExpandTableColumn(#"Index Partitions", "Partition", {"member", " enabled", "Index"}, {"member", " enabled", "Index"})
    in
        #"Expanded Partition"
    Load this query to the Data Model. Add a couple of measures:
    Member Name:=IF ( 
        HASONEVALUE ( powershell[member] ),
        VALUES ( powershell[member] ),
        BLANK()
    )
    Member Enabled:=IF ( 
        HASONEVALUE ( powershell[enabled] ),
        VALUES ( powershell[enabled] ),
        BLANK()
    )
    Now you can use CUBEVALUE formulae to display the names:
    Formula: copy to clipboard
    =CUBEVALUE("ThisWorkbookDataModel",
    CUBEMEMBER("ThisWorkbookDataModel","[powershell].[Index].&["&ROW()-1&"]"),
    CUBEMEMBER("ThisWorkbookDataModel","[Measures].[Member Name]"),
    A$1)


    Capture.png


    Finally, use a CUBEVALUE formula in conditional formatting, and format to suit:
    Formula: copy to clipboard
    =NOT(CUBEVALUE("ThisWorkbookDataModel",CUBEMEMBER("ThisWorkbookDataModel","[Measures].[Member Enabled]"),CUBEMEMBER("ThisWorkbookDataModel","[powershell].[Index].&["&ROW()-1&"]"),A$1))


    See https://excel.solutions/xlf_1269773/ for a worked example file.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  2. #2
    Registered User
    Join Date
    03-25-2019
    Location
    Brussels, Belgium
    MS-Off Ver
    2016 Pro
    Posts
    4

    Re: Sort Active Directory users by group

    Thanks, I've never used Power Query (Networking Student). I'll give it a try tomorrow, I have to be honest I don't understand what's going on at all. I thought this would be a lot simpler.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 04-18-2014, 05:54 PM
  2. Pull Active Directory Group Information into Excel
    By jam92102 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-20-2014, 04:32 PM
  3. Replies: 0
    Last Post: 09-05-2013, 10:00 AM
  4. How to add user to active directory group
    By Silencer001 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2013, 04:45 PM
  5. Active Directory Help
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-26-2011, 07:27 AM
  6. Get User Name - Active Directory
    By jai2808 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2007, 05:20 AM
  7. Active Directory References? help...
    By Judith in forum Excel General
    Replies: 1
    Last Post: 10-12-2006, 04:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1