# Ifelse function: group the same fields into multiple categories

Hello team, I am doing an average time analysis for a process and I need to create something like the following in a table:

Therefore, in the first row I need to see the data belonging to team A, in the next row team B, in the third row I need to see the average time of A and B together, and the data of the other teams in the team D.

I tried to use this formula:

``````ifelse(
{team_name} = "Team Jhon", "Team A",
{team_name} = "Team Sussan", "Team B",
{team_name} = "Team Jhon" OR {team_name} = "Team Sussan", "Team C",
"Team D")
``````

The problem is that the table shows me only the data of group A or B but not the combined ones, and if I place team C first in the sintax, then it does not show me the individual data of A and B.

Is there any way to do this?

Hey Danny,

This might not get you 100% percent the way there but itâ€™ll get you really close.

What you can do is make a separate calculated field that groups A & B together and the rest into a different group. Then you can add a row to your pivot table and take subtotals of your calculation.

group field = ifelse({team_name} = â€śTeam Jhonâ€ť OR {team_name} = â€śTeam Sussanâ€ť, â€śGroup Aâ€ť,â€śGroup Bâ€ť)

Here is how it might look.

You can also hide the group field and rename the subtotal rows.

Let me know if this helps.

3 Likes

@Max you hit the nail. I think sometimes itâ€™s important to have another point of view, and although itâ€™s not exactly what I was thinking, this solves my problem perfectly. Thanks a lot for your help.

1 Like