Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Compare Two Columns and instert New Column

mcloma
5 - Atom

Hello,

 

I am a new user and was hoping if I could get some help on a formula I am trying to use. Basically I have 1 excel file, that contains persons and their monthly bills for the last two months. I need to compare the current month's amount versus last month's amount and then insert a column that would tell me if the amounts are the same or not. In excel I would just use the formula =IF(B2=C2,"OK","CHECK").

 

A mock sample of how the spreadsheet would look like is below. I am hoping to populate the column "Compare Result" with either "OK" if July and August values are the same or "CHECK" if they are not using a formula in Alteryx.

 

mcloma_1-1629647706801.png

 

 

Thank you in advance.

 

3 REPLIES 3
Elias_Nordlinder
11 - Bolide

Hello @mcloma 

 

Here is a dynamic approach that would solve your problem.

I decided to do it dynamic if you wanted to check more months than just July and August.

 

Elias_Nordlinder_0-1629648758159.png

1. I use the transpose tool to convert the values to come below each other.

When they are below each other I can compare values that would be besides each other in the columns.

For example the July and August column (500 and 800 for Gary) will now look like this.

If there would be more columns (Months or Name, these would also work in this solution).

 

Elias_Nordlinder_2-1629648848435.png

 

2. MultiRow Formula: This is a great tool for dynamic approaches, for example checking if two rows below each other matches or not.

Here I want to check for example if the value 500 and 800 matches for Gary, I use the formula below:

 

Elias_Nordlinder_3-1629648948201.png

 

If the name Gary is the same on this row as the row before, and the value (800) is the same as the row before (500) or

if the name Gary is the same as the row after, and the value (500) is the same as the row after (800) then write "OK",

otherwise write "CHECK".

 

3. Use the CrossTab tool to get back to the original again.

I see this as the opposite to the Transpose tool.
The pattern Transpose -> Multi Row Formula -> Cross Tab is great for these kind of solution.

 

4. Select tool to remove unwanted columns.

 

Result:

 

Elias_Nordlinder_1-1629648763375.png

 

//Let me know if this solves your problem 🙂

 

Regards
Elias

anandshingi
5 - Atom

if you will be having only 2 months all the time in the dataset, 

 

use formula tool >> add new column and use formula 

if [July] = [August] then "OK" else "Check"
endif

mcloma
5 - Atom

thanks both for your help, I only need to check 2 months data all the time so ended up using @anandshingi solution and it worked fine.

Labels
Top Solution Authors