You can use a variety of methods as this is yet another example of the "sum if" problem.
You can set up two one row filtered portals with a summary field that sums the value field as the only field in the portal row. The relationship can match to all records or a sub set. The portal filter then specifies a specific value in the variable field so that one portal only allows a value of "x" in the variable field and the other specifies "y".
Two calculation fields can be defined that use ExecuteSQL with the Sum function and the appropriate WHERE clause can also produce these same totals.
And there are ways to set up relationships that match to only records with a variable field value of x and another that only matches when the value of the variable field is y and then a summary field or the sum function can compute this same total.
Other methods are also possible.