Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Compare two fields to populate a new column

I want to do a simple thing...

I want to compare two columns on my report.  If they're the same, I want a new column that says "Yes".

(I'm trying to see if comments were entered by an employee or his supervisor).

 

This doesn't work:

Column = if([CreatedByUser] = RELATED('Workers(2)'[User]), "Yes")
 
The error is "The column 'Workers(2)[User]' either doesn't exist or doesn't have a relationship to any table available in the current context."
So what's the deal?  Do the two tables have to be directly linked?  I can't do that...
These snips show the two fields that I'm trying to compare:
 

 

 

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    I very much appreciate the assistance from users on this forum!  I found that the solution for my situation was that I needed to do more in Power Query, rather than expecting to do column comparisons in the service.

     

    I first did a 'merge queries', bringing the two userid fields into one merged table.  From there, I added a custom column using an IF statement, populating my new column with data from the existing 'comments' column only if the two userIDs were different.  If they were the same, I put "remove" into the new column, instead of the comments.  Then, in a next step, I filtered rows and removed all rows containing the string "remove".

     

    I've got to remember that Power Query is where all the action is.

     

    Many thanks!

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    I very much appreciate the assistance from users on this forum!  I found that the solution for my situation was that I needed to do more in Power Query, rather than expecting to do column comparisons in the service.

     

    I first did a 'merge queries', bringing the two userid fields into one merged table.  From there, I added a custom column using an IF statement, populating my new column with data from the existing 'comments' column only if the two userIDs were different.  If they were the same, I put "remove" into the new column, instead of the comments.  Then, in a next step, I filtered rows and removed all rows containing the string "remove".

     

    I've got to remember that Power Query is where all the action is.

     

    Many thanks!

    • Anonymous's avatar
      Anonymous
      Not applicable

      I don't understand how LOOKUPVALUE would help.  I already have both fields on my report.  I just want to compare the two fields and, if they are the same, leave the new column blank.  If they are different, populate the new column.

       

       

      • vapid128's avatar
        vapid128
        Icon for Solution Specialist rankSolution Specialist

        Measure:

        isSame = 

        IF(MAX(TableName[User])=MAX(TableName[CreateByUser]),"YES","NO")