PostgreSQL: How to get a sum of values and the total rows that went into each value?
I have created the following sample DDL structure in order to work the necessary queries:

CREATE TABLE my_data
(
    my_data_id  SERIAL,
    theme_id    INT NOT NULL,
    priority_id INT NOT NULL,  
    my_value    INT NOT NULL,
    CONSTRAINT pk_my_data PRIMARY KEY (my_data_id)  
);

CREATE TABLE theme
(
    theme_id  SERIAL,
    name      CHAR(6) NOT NULL,
    CONSTRAINT pk_theme PRIMARY KEY (theme_id)  
);

CREATE TABLE priority
(
    priority_id  SERIAL,
    name         CHAR(6) NOT NULL,
    CONSTRAINT pk_priority PRIMARY KEY (priority_id)  
);


Then, inserted the following test data into the respective tables:

INSERT INTO theme (name)
VALUES ('first');
INSERT INTO theme (name)
VALUES ('second');
INSERT INTO theme (name)
VALUES ('third');

INSERT INTO priority (name)
VALUES ('high');
INSERT INTO priority (name)
VALUES ('medium');
INSERT INTO priority (name)
VALUES ('low');

INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (1, 1, 6);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (1, 2, 5);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (1, 3, 8);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (1, 1, 3);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (1, 2, 4);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (1, 3, 11);

INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (2, 1, 7);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (2, 2, 3);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (2, 3, 9);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (2, 1, 1);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (2, 2, 13);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (2, 3, 10);

INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (3, 1, 1);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (3, 2, 8);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (3, 3, 2);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (3, 1, 6);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (3, 2, 5);
INSERT INTO my_data (theme_id, priority_id, my_value)
VALUES (3, 3, 4);


And, finally the concrete SELECT statement with its corresponding aggregate functions that provide your desired result set:

SELECT theme_id, 
       priority_id, 
       SUM(my_value) AS values_sum, 
       COUNT(*)      AS total_rows
  FROM my_data
GROUP BY theme_id, priority_id 
ORDER BY theme_id ASC, priority_id ASC;


In this way, we can see that you almost had it with your second query but, as @a_horse_with_no_name has pointed out, you needed to replace count(id) with count(*), so that you could get your correct data. I have also included the ORDER BY clause for sorting the columns.

By means of this SQL Fiddle sample, you can confirm that the results yielded by SUM and COUNT are correct. As you can see I've added theme and priority, which are relevant tables for this query, along with the required test data.