Forum Discussion

ccianci's avatar
ccianci
Frequent Visitor
4 years ago
Solved

Fixing inconsistent names & missing titles

Hello all,

 

I have two issues I'm hoping you can help me with.  I'm fairly new to Power BI & Power Query and i'm working on a PBI report comparing joiners vs leavers over the last x years.  For your reference, the raw data file actually uses the values "joiners" and "leavers":

  1. One issue is the employee title.  In the query, all new hires have a title but the leavers do not.  My thought to get some of the data fixed is to do an XLOOKUP or similar formula.  Basically, it would be something like this - if the leaver's title is empty, then search all joiners for the full name.  if there's a match, copy the title over.  I know this wont fix all leavers but it should fix some. Since all the joiners and leavers are in one table, i thought it would be easiest to duplicate the query so there's one for joiners and one for leavers.  not sure if that helps or just makes things harder.

  2. The second issue is related to the one above.  I can't search for the user's name because the "full name" column was poorly entered by HR.  Some names are FIRST LAST and some are LAST, FIRST.  Some even have two spaces between FIRST LAST.
    Is there a power query formula I can use to clean this up or maybe create a new column with a uniform value - FIRST LAST?

 

Thank you for your help.

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi ccianci ,

     

    You may add a new column:

    Filled Title = 
    var _title= CALCULATE(MAX('Table'[Title]),ALLEXCEPT('Table','Table'[Email]))
    return IF([Title]=BLANK(),_title,[Title])

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • ccianci's avatar
    ccianci
    Frequent Visitor

    Thank you both.  Here's a sample data (cleaned for privacy) of what I'm talking about:

     

    ItemFull NameNameEmailTitleStart DateLeaving Date
    JoinerDoe, John [email protected]Vice President2022-05-16 
    JoinerLow, Karen [email protected]Consultant2022-03-21 
    Leaver Karen Low[email protected]  2022-05-15

     

    First issue: Leaver title is missing (line 4) but since that same employee joined this year (line 3).  Is there a way to do a search in Power Query (or dax) to fill in that title?  If the search returns nothing, then leave the title blank.

     

    Second issue: cancel this one - i figured out a solution using Power Query

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ccianci ,

     

    You may add a new column:

    Filled Title = 
    var _title= CALCULATE(MAX('Table'[Title]),ALLEXCEPT('Table','Table'[Email]))
    return IF([Title]=BLANK(),_title,[Title])

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.