Excel: How do you count all cells to the right that have an "x" and display the number?

时间:2017-08-30 20:32:36

标签: excel

I know =countif(cell_range, "x") will return the number of cells that have "x" but I would like to reference cells to the right.

I have tried the R1C1 annotation -> "RC[1]:RC[31]"... but it has not worked for me.

Does anyone know. I would like to copy paste this formula without having to tweak it.

2 个答案:

答案 0 :(得分:1)

I'm gonna go out on a limb and say that you are probably using Google Sheets.

If so, relative cell referencing is inherent with the default A1 annotation.

You can take it and copy paste it anywhere and the formula will adjust the cell reference (relatively, ;D).

To reference absolute cells u would use $A$1 annotation.

$A references column A no matter where you paste it. $1 references row 1 no matter where you paste it.

答案 1 :(得分:0)

Your idea worked perfectly for me:

A = LOAD 'product_details.csv' using PigStorage(',') AS(col1:int,col2:chararray,col3:chararray);
B = FOREACH A GENERATE col1,FLATTEN(TOKENIZE(col2,'|')) AS letter;
C = GROUP B BY (col1,letter);
D = FOREACH C GENERATE FLATTEN(group) as (product,letter),COUNT(B.letter) as total;
E = FILTER D BY (letter == '1');
F = ORDER E BY total DESC;
G = LIMIT F 1;
DUMP G;

Without a reproducible example of your data, though, there's no way to tell if you have an error somewhere. I'm assuming you also have R1C1 references turned on in the option menu.