Forum Discussion
TomLU123
8 years agoHelper III
Validate the data within the same table
Dear Experts, I wish to building a report to validate the supervisro ID of the employee. The conditions are like this: If it is blank, it is invalid. If it contains non-numerical character...
- 8 years ago
Please check if attached file helps
Column = SWITCH ( TRUE (), [Supervisor ID] = "" || [Supervisor ID] = [Employee ID] || AND ( [Text in Supervisor ID] <> "", NOT ( CONTAINS ( VALUES ( Table1[Text in Employee ID] ), Table1[Text in Employee ID], [Text in Supervisor ID] ) ) ), "Invalid", "Valid" ) - 8 years ago
In that case, modify as follows
Column = SWITCH ( TRUE (), [Supervisor ID] = "" || [Supervisor ID] = [Employee ID] || AND ( [Text in Supervisor ID] <> "", NOT ( CONTAINS ( VALUES ( Table1[Employee ID] ), Table1[Employee ID], [Supervisor ID] ) ) && NOT ( CONTAINS ( VALUES ( Table1[Legacy ID] ), Table1[Legacy ID], [Supervisor ID] ) ) ), "Invalid", "Valid" )
Zubair_Muhammad
8 years agoCommunity Champion
Please check if attached file helps
Column =
SWITCH (
TRUE (),
[Supervisor ID] = ""
|| [Supervisor ID] = [Employee ID]
|| AND (
[Text in Supervisor ID] <> "",
NOT (
CONTAINS (
VALUES ( Table1[Text in Employee ID] ),
Table1[Text in Employee ID], [Text in Supervisor ID]
)
)
), "Invalid",
"Valid"
)TomLU123
8 years agoHelper III
Hi Zubair_Muhammad,
What if we have additional column that needs to compare. Pelase find the condition for Supervisor ID column as below:
- If it is blank, it is invalid.
- If it contains non-numerical characters and can not be found in both employee ID column and Legacy ID column, it is invalid.
- If the supervisor ID is the same as his employee ID, it is invalid.
- Else are valid.
Here is the sample dataset:
| Legacy ID | Employee ID | Supervisor ID | Validation Result |
| WS2001 | WS2001 | 7345382 | Valid |
| WS2002 | WS2002 | Invalid (it is blank) | |
| WS2003 | WS2003 | WS2001 | Valid (it can be found in the employee ID coulmn) |
| WS2004 | WS2004 | WS2004 | Invalid (it is the same as this employee's ID) |
| XA1333 | XA1333 | WS2001 | Valid (it can be found in the employee ID coulmn) |
| 3C211 | MZ2555 | BA2111 | Invalid (it can not be found in the employee ID coulmn) |
| MZ43333 | MZ43333 | 3C211 | Valid (it can be found in Legacy ID column) |
| MZ55555 | MZ55555 | 63C111 | Invalid (it can not be found in both Legacy ID and Employee ID column) |
How should we modify the DAX to achieve it?
Many thanks for your great help!
- Zubair_Muhammad8 years agoCommunity Champion
In that case, modify as follows
Column = SWITCH ( TRUE (), [Supervisor ID] = "" || [Supervisor ID] = [Employee ID] || AND ( [Text in Supervisor ID] <> "", NOT ( CONTAINS ( VALUES ( Table1[Employee ID] ), Table1[Employee ID], [Supervisor ID] ) ) && NOT ( CONTAINS ( VALUES ( Table1[Legacy ID] ), Table1[Legacy ID], [Supervisor ID] ) ) ), "Invalid", "Valid" )