Using Matomo 3.13.0 and Custom Reports 3.1.23 (this also happened with previous Matomo / Custom report versions) we see a calculation bug when An Action Dimension is used in conjunction with a GoalID metric.
As a basic example if we had the following:
Action Dimension name “Color” with red, blue, green as values that get set on Page 1 and a goal, “Goal 1” also being set on page 1 unrelated to the color value and being set just by accessing the page (which can be set multiple times per visit), the goal count is incorrect in a Custom report where the Action dimension “color” is used as a Report dimension and “Goal 1 Conversion Count” is used as a metric.
Basically what we see is that the goal count metric isn’t constrained by each Action dimension value row. An example with the following sample traffic:
Visitor 1
Visit 1: Page 1, color red, goal fired
Visit 2: Page 1, color blue, goal fired
Visit 3: Page 1, color green, goal fired
Visitor 2
Visit 1: Page 1, color red, goal fired
Visit 2: Page 1, color green, goal fired
In a custom report defined as above we should see:
Color, GoalID Conversion
red,2
blue,1
green,2
What we actually see is:
Color, GoalID Conversion
red,5
blue,1
green,5
Glancing through the code it seems to be an issue in the Querybuilder.php file. Happy to share real data/repro cases as needed to help diagnose and resolve. Thanks.