# <Excel Automation> Comparing 2 column and write final value in another column

I want to put value in column C/Final color wrt column A/order number and column B/color.
For e.g.

1. same order number will have same color in final color column.
2. But final color value in Final color column for respective Order Number depends on preference of color.

Preference of color will be as per below criteria:
a. Value of Final color cell needs to be white only when all of them are white.
b. Value will be Yellow if any of them is Yellow
c. Value will be green only if all of them is green.

Would prefer if someone can provide a excel formula for same instead of going via UiPath. Thanks in advance.

Want similar solution like this:

=LET(Matrixvals;CHOOSECOLS(UNIQUE(FILTER(\$A\$2:\$B\$9;\$A\$2:\$A\$9=A2);FALSE;FALSE);2);
IFS(
ISNUMBER(MATCH(â€śwhiteâ€ť;Matrixvals;0));â€śwhiteâ€ť;
ISNUMBER(MATCH(â€śyellowâ€ť;Matrixvals;0));â€śyellowâ€ť;
ISNUMBER(MATCH(â€śgreenâ€ť;Matrixvals;0));â€śgreenâ€ť;
TRUE;â€śn/aâ€ť
))

Could you try the below excel formula and let me know itâ€™s working or not,

``````=IF(COUNTIFS(A:A, A2, B:B, "White")=COUNTIFS(A:A, A2), "White", IF(COUNTIFS(A:A, A2, B:B, "Yellow")>0, "Yellow", "Green"))
``````

Hope it helps!!

2 Likes

Hi @mkankatala ,

Thank you so much for your help,

But, Itâ€™s not fulfilling one criteria:
When for e.g. Colour column has 2 white and 1 green for same order number 4, final color should be Yellow.

Sorry it was not mentioned in question asked.

Final color output should be like this:

Is the above expression working for you excluding the new rule @anjasing

Yes, itâ€™s working for me.

Try the below one and let me know, @anjasing

``````=IF(COUNTIFS(A:A, A2, B:B, "White")=COUNTIFS(A:A, A2), "White",
IF(COUNTIFS(A:A, A2, B:B, "Yellow")>0, "Yellow",
IF(COUNTIFS(A:A, A2, B:B, "Green")=1, "Yellow", "Green")))
``````

Hope it helps!!

1st one is only coming yellow, which should be green. Everything else is fine. @mkankatala

Provide the output that you have got, share the excel file if possible @anjasing

Excel Output.xlsx (9.2 KB)

Try this one @anjasing

``````=IF(COUNTIFS(A:A, A2, B:B, "White")=COUNTIFS(A:A, A2), "White",
IF(COUNTIFS(A:A, A2, B:B, "Yellow")>0, "Yellow",
IF(COUNTIFS(A:A, A2, B:B, "Green")=COUNTIFS(A:A, A2), "Green", "Yellow")))
``````

Check the below output,

Hope you understand!!

1 Like

Yes, it works. Thank you so much

Itâ€™s my pleasureâ€¦ @anjasing

Happy Automation!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.