Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
shirleyc40
Creator
Creator

Distinct count of fieldA != fieldB

Hello!

I have data from a SQL DB that looks similar to this: 

idreported statusactual status
1successsuccess
1failsuccess
2undeterminedundetermined
3undeterminedsuccess
3-fail
3failfail

 

I'm trying to count the number rows that have reported status != actual status . I have this as my equation: 

Count ({<[reported status] -={"=[actual status]"}>} id). However, this is giving me a count that is too high, compared to when I check it in the SQL database. If I do unique id, I get a lower number but it isn't the right count either.

 

Labels (1)
5 Replies
Anil_Babu_Samineni

Perhaps this?

Count ({<id = {"=[reported status]<>[actual status]"}>} id)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
GaryGiles
Specialist
Specialist

This probably is not the most efficient way to accomplish, but should return the correct results.

count(if(reported_status<>actual_status,id))

Chanty4u
MVP
MVP

try  below

sum(if(reported status <> actual statusAggr(Distinct(id),reported status ,actual status)) )

avinashelite

With the above sample data your excepting the output count to be 2 or  4

shirleyc40
Creator
Creator
Author

why is a sum?