Here I present you a recommended flow to analyze queries that return unexpected data. It can guide you finding out whether it happens due to a bug in the software or show you that your expectation is not correct.
Start testing the query at T-Code RSRT (HTML mode). This flow assumes that you can see the unexpected values even when executing the query there. The numbers between parenthesis refer to an SAP Note where you can find details on how to execute that step. The direct link to those notes can be found in the end of this post.
Step 1: Execute the query at RSRT (HTML mode) using the button Execute + Debug and selecting Safe Mode. See SAP KBA 2125357.
Step 2a: In case you get the expected/correct results when running the query in Safe Mode the issue most likely lies on Aggregates, BIA/HANA indexes, Cache or DB Optimizations. Use the instructions in the SAP KBA 2142771 to narrow down which one is causing the error. Search for notes in that area. In case you cannot find any relevant, open an incident under the component shown in the picture above.
Step 2b: In case you still get unexpected/wrong results even in Safe Mode, you will need to simplify your query. You can find how to do that in the SAP Note 1125883.
Step 3: Now that you got a simpler query it's possible to compare the query results against the values in the InfoProvider. To make it easier to investigate, create a LISTCUBE report as explained in the SAP KBA 2055174.
Step 3a: In many cases, after doing all the above steps one can find out that the results in the query are correct and some mistake was made when designing the query. Other times there is really a failure in the software doing the calculations. In this last case, log an incident under BW-BEX-OT-OLAP component.
Step 3b: If the values of the Basic Key Figures in the query don't match their values in the cube there's likely a bug in the application. Log an incident under BW-BEX-OT-OLAP component.
In case you need to create an incident, whatever the component is, provide the technical name of your simplified query and the LISTCUBE report.