We have finished a story which is no longer required by the Product Owner (PO) or Management. The completed story is not going to add any business value. What should we do in this case? Should we count the effort in our velocity or not?
We have finished a story which is no more required by PO/Management. Surely this story is not going to add any business value. What to do in this case? Should we count the effort in velocity or not?
Velocity is primarily (and most effectively) a metric for estimating a team's capacity to do future work within a Sprint or series of Sprints, and is not intended to be a measure of productivity or business value. Because it estimates future capacity based on historical performance, you should take that into account when determining how to track your velocity.
In your specific case, which is rather sparse on detail, I would suggest the following rules of thumb:
If the story was taken on at the start of the Sprint during Sprint Planning, and if the work was delivered at the end of the Sprint in accordance with the Definition of Done, then the work is legitimately counted towards velocity because it correctly expresses work planned/completed during the Sprint.
Likewise, if the story lost its value during the Sprint for some reason, but the Product Owner chose not to take it out of scope or terminate the Sprint early as a result, then the work still properly measures the team's capacity to deliver work.
If the story was not completed in accordance with the Definition of Done, then the work can not be counted towards the team's velocity.
If the Sprint Goal was achieved, whether or not the Product Owner asked for it to be removed from the Sprint, then whether or not to count the work towards velocity basically comes down to how you wish to communicate about the velocity metric: as planned/completed work, or as a value or opportunity cost. Obviously, I lean towards the former, but some practitioners may legitimately disagree.
On the one hand, counting work towards velocity reflects planned work completed. On the other hand, not counting it makes invalidated work visible as a drag on velocity.
As long as you aren't making the fundamental error of trying to make velocity reflect effort or time expended, and are consistent in your use of the velocity metric to communicate about the status of the project, then how the team deals with a one-off situation like this shouldn't have much impact on a velocity metric expressed as a range or trailing average.
There are certainly exceptions, such as very short projects or framework implementation failures, but in general this should be a non-event that's addressed in the Sprint Retrospective. However, your mileage may vary.
Great learning opportunity
If the work was done based on the PO prioritizing the work, yes you should count it in velocity. It is possible market conditions changed.
If the dev team went ahead on their own, then you cannot count it in velocity. Key takeaway is to tighten up your process and take up work only if prioritized by the PO.
If there was a misunderstanding between the PO and dev team, then you should tighten up your communication and feedback.
Regardless, this is a great learning opportunity. It is time for a retrospective to identify the root cause and come up with ways to avoid a similar debacle again.