'Countrows duplicates powerbi

I have status log table which contains: student name and results, and a Status table containing 3 categories: attemped, Failed and Passed.

A student can attempt an exam for 5 times. If he failed for first 3 times and then passed in 4th attempt, then he should no longer remain in failed count. When I try to filter only failed students, I am getting his previous failed counts also. The powerbi row context considering his previous failed count as values.

Sample date:

https://drive.google.com/file/d/1_6DnTIMKfn-sCs_OkSaDNZYv69S9Floh/view?usp=sharing

Failed count should be 1.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source