Forum Discussion
how to compare row values based on multiple criteria
- 6 years ago
Anonymous
Hi, Add the following DAX code as a new column in your table and correct the table and column names as necessary.Job Change Status = VAR U = [User ID] VAR Y = [Job Year] VAR _TABLE = FILTER( ADDCOLUMNS( FILTER ( GENERATE ( 'merit 18-21', SELECTCOLUMNS ( 'merit 18-21', "2YR", 'merit 18-21'[Job Year], "2BAND", 'merit 18-21'[band], "2JOB", 'merit 18-21'[JobCode2], "2USER", 'merit 18-21'[User ID] ) ), 'merit 18-21'[User ID] = [2USER] && 'merit 18-21'[Job Year] = [2YR] + 1 ), "Job Change", SWITCH( TRUE(), NOT('merit 18-21'[band] > [2band]) && 'merit 18-21'[JobCode2] = [2JOB], "NO CHANGE", 'merit 18-21'[band] > [2band], "PROMOTION", NOT('merit 18-21'[band] > [2band]) && 'merit 18-21'[JobCode2] <> [2JOB], "LATERAL JOB MOVEMENT", "STATUS NOT IDENTIFIED" ) ), 'merit 18-21'[User ID] = U && 'merit 18-21'[Job Year] = Y ) RETURN MAXX(_TABLE,[Job Change])________________________
Did I answer your question? Mark this post as a solution, this will help others!.
Click on the Thumbs-Up icon if you like this reply 🙂
Thanks for coming back, Harsh.
I made a bit update to remove syntax error (see below), the commands works with no error message, but the result is not correct. It doesn't work when there is no previous data (e.g., only 2018 data exist for user id 00001).
I'm also wondering if MAX formula will work when it deals with a text column (here column JobCode2)?
Hi Anonymous ,
Can you share some sample data in text format.
You can remove all sensitive information
Regards,
Harsh Nathani