如何按条件间隔对结果进行分组

How to group results by intervals with condition

G-绿色 A-琥珀色 R-红色

如果值小于 8,则应为红色,介于 8 和 9 之间,应为琥珀色,高于 9,则为绿色。

我还需要对结果进行分组,例如:如果结果是 GAR(绿色、琥珀色和红色),我需要一个值为 "Not Good",如果值为 RAG(红色、琥珀色和绿色)它应该是 "Good",如果全是红色,它就是 "Poor"

如何对红色、琥珀色和绿色进行分组?

+---------+---------+------+--------+-------+
| PROJECT | SUBTASK | TASK | PERIOD | VALUE |
+---------+---------+------+--------+-------+
| A       | AA      | AAA  |      1 |     6 |
| A       | AA      | AAA  |      2 |    8.2|
| A       | AA      | AAA  |      3 |    10 |
| B       | BB      | BBB  |      1 |    10 |
| B       | BB      | BBB  |      2 |     9 |
| B       | BB      | BBB  |      3 |     6 |
| C       | CC      | CCC  |      1 |     7 |
| C       | CC      | CCC  |      2 |     7 |
| C       | CC      | CCC  |      3 |     6 |
+---------+---------+------+--------+-------+

输出

+---------+---------+------+---+---+---+
| PROJECT | SUBTASK | TASK | 1 | 2 | 3 |
+---------+---------+------+---+---+---+
| A       | AA      | AAA  | R | A | G |
| B       | BB      | BBB  | G | G | R |
| C       | CC      | CCC  | R | R | R |
+---------+---------+------+---+---+---+

最终输出

+---------+---------+------+----------+
| PROJECT | SUBTASK | TASK |  Result  |
+---------+---------+------+----------+
| A       | AA      | AAA  | Good |
| B       | BB      | BBB  | Not Good |
| C       | CC      | CCC  | Poor     |
+---------+---------+------+----------+

根据编辑后的示例数据,规则应该是 >= 9 与 > 9。考虑到这一点,这里是步骤

插入计算列并将其命名为[CalcCol]

case  
when [VALUE]<8 then "R" 
when ([VALUE]>=8) and ([VALUE]<9) then "A" 
when [VALUE]>=9 then "G"
end

插入计算列并将其命名为[Concat]

Substitute(Substitute(Concatenate([CalcCol]) over (Intersect([PROJECT],[SUBTASK],[TASK])),",","")," ","")

插入计算列并将其命名为[FinalOutput]

case  
when [Concat]="RAG" then "Good" 
when [Concat]="GGR" then "Not Good" 
when [Concat]="RRR" then "Poor"
end

现在,您将在常规 table 视图或交叉 table 视图中看到您的结果,其中 Max([FinalOutput]) 作为单元格值,垂直轴设置为项目,按此顺序执行子任务、任务。