Forum Discussion
Detecting duplicates for data validation across multiple tables for non-zero values
Pulling out my hair over this one.
I need to determine if non-zero duplicates are present within a data submission. Specifically, I tried to solve this by checking whether or not for non-zero values, the count of values was equal to the distinct count of data ID values for a submission.
Sample Data and expected results:
SubmissionBreakdown table
| SubmissionId | DataId |
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 2 | 0 |
| 2 | 2 |
| 2 | 3 |
| 2 | 4 |
| 3 | 0 |
| 3 | 2 |
| 3 | 2 |
| 3 | 4 |
SubmissionId table
| SubmissionId | ProtocolCheck |
| 1 | 1 |
| 2 | 1 |
| 3 | 0 |
- Anonymous4 years ago
The solution didn't work but solved it in a different way - simply counted the number of data points of a particular value and then flagged if it was over an acceptable value i.e. if there was more than 1 of a value, it fails protocol through an if statement.
Sample here checks whether or not there are too many ones or twos. To keep going for 3 and 4, just nest the OR statements.If(OR(If(Countrows(CALCULATETABLE(SubmissionBreakdown, Filter(SubmissionBreakdown, SubmissionBreakdown[DataId] = 1), Filter(SubmissionBreakdown, SubmissionBreakdown[SubmissionId] = Submission[submissionid]))) > 1, 1, 0), If(Countrows(CALCULATETABLE(SubmissionBreakdown, Filter(SubmissionBreakdown, SubmissionBreakdown[DataId] = 2), Filter(SubmissionBreakdown, SubmissionBreakdown[SubmissionId] = Submission[submissionid]))) > 1, 1, 0)) = TRUE, 1, 0)
2 Replies
- Greg_DecklerCommunity Champion
Anonymous Maybe:
Protocol Check = VAR __Count1 = COUNTROWS('Table') VAR __Count2 = COUNTROWS(SUMMARIZE('Table',[SubmissionID],[DataId])) RETURN IF(__Count1 = __Count2,1,0) - AnonymousNot applicable
The solution didn't work but solved it in a different way - simply counted the number of data points of a particular value and then flagged if it was over an acceptable value i.e. if there was more than 1 of a value, it fails protocol through an if statement.
Sample here checks whether or not there are too many ones or twos. To keep going for 3 and 4, just nest the OR statements.If(OR(If(Countrows(CALCULATETABLE(SubmissionBreakdown, Filter(SubmissionBreakdown, SubmissionBreakdown[DataId] = 1), Filter(SubmissionBreakdown, SubmissionBreakdown[SubmissionId] = Submission[submissionid]))) > 1, 1, 0), If(Countrows(CALCULATETABLE(SubmissionBreakdown, Filter(SubmissionBreakdown, SubmissionBreakdown[DataId] = 2), Filter(SubmissionBreakdown, SubmissionBreakdown[SubmissionId] = Submission[submissionid]))) > 1, 1, 0)) = TRUE, 1, 0)