How to compare two fields within an analysis
How do I compare two fields in an analysis. I need "Workforce Management - Person Real Time"."Person Legislative Information"."Country" equal to "Legal Employer"."Legislation"
Thank you
Ruth,
Within an analysis this can be accomplished by a CASE statement, where 'True' is the behavior if there is a match and 'False' if there is not:
CASE WHEN "Workforce Management - Person Real Time"."Person Legislative Information"."Country" = "Legal Employer"."Legislation" THEN 'True' ELSE 'False' END
If you are filtering on this criteria you will want to check "Convert this filter to SQL" and then set the SQL filter to "Workforce Management - Person Real Time"."Person Legislative Information"."Country" = "Legal Employer"."Legislation"
I entered the case setting a filter on one of the two columns and using convert to SQL. I then put in the "Workforce Management - Person Real Time"."Person Legislative Information"."Country" = "Workforce Management - Work Relationship Real Time"."Legal Employer"."Legislation" When I view the results I receive a huge error.
For testing purposes, does the analysis work if you remove Legal Employer.Effective End Date (or one of the two other fields suggested: Legal Employer.Effective Start Date or Legal Employer.OrgUnitClassificationId)? Adding CAST to the filter fields may change the behavior but you'll want to test removing those fields first.
Yes if I remove the filter the analysis works fine. I'm attaching a screenshot of my filter, perhaps I'm doing something incorrectly.
Thanks,
Ruthie
Please add a screenshot of entire Advanced SQL Filter.
I tested a similar situation that worked. Please refer to the following screenshot. I guess you are missing "='Ture'" or "='False'" criteria based on your need.
If this answers your question than please mark this question as answered.
You should be able to set the fields equal to each other without the case statement using the Advanced SQL Filter
The applied filter would look like this:
CASE WHEN "Workforce Management - Person Real Time"."Person Legislative Information"."Country" = "Workforce Management - Worker Assignment Real Time"."Legal Employer"."Legislation" THEN 'True' ELSE 'False' END
I'm also attaching the entire error message I'm receiving.
If the fields are different types this is the cast function I referenced above:
Did you built this statement manually? Please try to use Expression Builder to build the same statement. Even converting filter to SQL statement filter is not required. You will be still able to filter the data just like a normal column.
Can you please go to Advanced tab of analysis and copy & paste text in SQL Issued text box? It will allow me to duplicate your analysis to debug this issue.