Hi Excel Guru's
Need help please, I know what my logic should be, I know what my result should be, but I am unable to build any formula to show the result I need.
Below is the data set up and three different scenarios. The column named [Primary File Number line TAG] is where I would like to add the formula.
Hope I can get someone to figure this out.
[TABLE="class: grid, width: 1048"]
<colgroup><col><col><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]File Number[/TD]
[TD]Customer Account Number[/TD]
[TD]Customer Account Name[/TD]
[TD]Account Owner Role[/TD]
[TD]Invoice Number[/TD]
[TD]Invoice Date[/TD]
[TD]Invoice Amount[/TD]
[TD]Profit Amount of File Number[/TD]
[TD]Primary File Number line TAG[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902641[/TD]
[TD]7687804833[/TD]
[TD]Xxonel LLC[/TD]
[TD]Generic[/TD]
[TD="align: right"]9050867611[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]282[/TD]
[TD="align: right"]8278.44[/TD]
[TD]Ignore[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902641[/TD]
[TD]76878038[/TD]
[TD]Lion Inc[/TD]
[TD]Sales[/TD]
[TD="align: right"]9050867538[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]997[/TD]
[TD="align: right"]8278.44[/TD]
[TD]Ignore[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902641[/TD]
[TD]76877995[/TD]
[TD]Bugs be gone[/TD]
[TD]Sales[/TD]
[TD="align: right"]9050867581[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]7974[/TD]
[TD="align: right"]8278.44[/TD]
[TD]Primary[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902641[/TD]
[TD]76878048445[/TD]
[TD]Geeks & Leeks[/TD]
[TD]Generic[/TD]
[TD="align: right"]9050867616[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]85469[/TD]
[TD="align: right"]8278.44[/TD]
[TD]Ignore[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]File Number[/TD]
[TD]Customer Account Number[/TD]
[TD]Customer Account Name[/TD]
[TD]Account Owner Role[/TD]
[TD]Invoice Number[/TD]
[TD]Invoice Date[/TD]
[TD]Invoice Amount[/TD]
[TD]Profit Amount of File Number[/TD]
[TD]Primary File Number line TAG[/TD]
[/TR]
[TR]
[TD="align: right"]71107569089307[/TD]
[TD]1390063[/TD]
[TD]Bradley's Oranges[/TD]
[TD]Sales[/TD]
[TD="align: right"]300955233[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]111[/TD]
[TD="align: right"]5936.19[/TD]
[TD]Primary[/TD]
[/TR]
[TR]
[TD="align: right"]71107569089307[/TD]
[TD]1455039[/TD]
[TD]Olivia & Company[/TD]
[TD]Generic[/TD]
[TD="align: right"]300955430[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]24569[/TD]
[TD="align: right"]5936.19[/TD]
[TD]Ignore[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]File Number[/TD]
[TD]Customer Account Number[/TD]
[TD]Customer Account Name[/TD]
[TD]Account Owner Role[/TD]
[TD]Invoice Number[/TD]
[TD]Invoice Date[/TD]
[TD]Invoice Amount[/TD]
[TD]Profit Amount of File Number[/TD]
[TD]Primary File Number line TAG[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902392[/TD]
[TD]7687804833[/TD]
[TD]Xxonel LLC[/TD]
[TD]Generic[/TD]
[TD="align: right"]9050867580[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]5854[/TD]
[TD="align: right"]4331.82[/TD]
[TD]Ignore[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902392[/TD]
[TD]76878048[/TD]
[TD]Sunshine Tailers[/TD]
[TD]Generic[/TD]
[TD="align: right"]9050867579[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]27465[/TD]
[TD="align: right"]4331.82[/TD]
[TD]Primary[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]The logic I need[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 9"]if [account owner role] = "sales" then return "primary" BUT if there are two or more [account owner role] which return as "sales" for same [file number] then return whichever [account owner role] with "sales" row has the highest [Invoice Amount] and return as "Primary". all other rows for the same file number to be tagged as "ignore".[/TD]
[/TR]
[TR]
[TD="colspan: 9"]if all rows for the same [file number] does not contain [account owner role] "sales" then the row with the highest [Invoice amount] if to be tagged as "primary", all others tagged as "ignore".[/TD]
[/TR]
</tbody>[/TABLE]
Need help please, I know what my logic should be, I know what my result should be, but I am unable to build any formula to show the result I need.
Below is the data set up and three different scenarios. The column named [Primary File Number line TAG] is where I would like to add the formula.
Hope I can get someone to figure this out.
[TABLE="class: grid, width: 1048"]
<colgroup><col><col><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]File Number[/TD]
[TD]Customer Account Number[/TD]
[TD]Customer Account Name[/TD]
[TD]Account Owner Role[/TD]
[TD]Invoice Number[/TD]
[TD]Invoice Date[/TD]
[TD]Invoice Amount[/TD]
[TD]Profit Amount of File Number[/TD]
[TD]Primary File Number line TAG[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902641[/TD]
[TD]7687804833[/TD]
[TD]Xxonel LLC[/TD]
[TD]Generic[/TD]
[TD="align: right"]9050867611[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]282[/TD]
[TD="align: right"]8278.44[/TD]
[TD]Ignore[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902641[/TD]
[TD]76878038[/TD]
[TD]Lion Inc[/TD]
[TD]Sales[/TD]
[TD="align: right"]9050867538[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]997[/TD]
[TD="align: right"]8278.44[/TD]
[TD]Ignore[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902641[/TD]
[TD]76877995[/TD]
[TD]Bugs be gone[/TD]
[TD]Sales[/TD]
[TD="align: right"]9050867581[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]7974[/TD]
[TD="align: right"]8278.44[/TD]
[TD]Primary[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902641[/TD]
[TD]76878048445[/TD]
[TD]Geeks & Leeks[/TD]
[TD]Generic[/TD]
[TD="align: right"]9050867616[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]85469[/TD]
[TD="align: right"]8278.44[/TD]
[TD]Ignore[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]File Number[/TD]
[TD]Customer Account Number[/TD]
[TD]Customer Account Name[/TD]
[TD]Account Owner Role[/TD]
[TD]Invoice Number[/TD]
[TD]Invoice Date[/TD]
[TD]Invoice Amount[/TD]
[TD]Profit Amount of File Number[/TD]
[TD]Primary File Number line TAG[/TD]
[/TR]
[TR]
[TD="align: right"]71107569089307[/TD]
[TD]1390063[/TD]
[TD]Bradley's Oranges[/TD]
[TD]Sales[/TD]
[TD="align: right"]300955233[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]111[/TD]
[TD="align: right"]5936.19[/TD]
[TD]Primary[/TD]
[/TR]
[TR]
[TD="align: right"]71107569089307[/TD]
[TD]1455039[/TD]
[TD]Olivia & Company[/TD]
[TD]Generic[/TD]
[TD="align: right"]300955430[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]24569[/TD]
[TD="align: right"]5936.19[/TD]
[TD]Ignore[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]File Number[/TD]
[TD]Customer Account Number[/TD]
[TD]Customer Account Name[/TD]
[TD]Account Owner Role[/TD]
[TD]Invoice Number[/TD]
[TD]Invoice Date[/TD]
[TD]Invoice Amount[/TD]
[TD]Profit Amount of File Number[/TD]
[TD]Primary File Number line TAG[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902392[/TD]
[TD]7687804833[/TD]
[TD]Xxonel LLC[/TD]
[TD]Generic[/TD]
[TD="align: right"]9050867580[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]5854[/TD]
[TD="align: right"]4331.82[/TD]
[TD]Ignore[/TD]
[/TR]
[TR]
[TD="align: right"]78512568902392[/TD]
[TD]76878048[/TD]
[TD]Sunshine Tailers[/TD]
[TD]Generic[/TD]
[TD="align: right"]9050867579[/TD]
[TD="align: right"]8/1/2019[/TD]
[TD="align: right"]27465[/TD]
[TD="align: right"]4331.82[/TD]
[TD]Primary[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]The logic I need[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 9"]if [account owner role] = "sales" then return "primary" BUT if there are two or more [account owner role] which return as "sales" for same [file number] then return whichever [account owner role] with "sales" row has the highest [Invoice Amount] and return as "Primary". all other rows for the same file number to be tagged as "ignore".[/TD]
[/TR]
[TR]
[TD="colspan: 9"]if all rows for the same [file number] does not contain [account owner role] "sales" then the row with the highest [Invoice amount] if to be tagged as "primary", all others tagged as "ignore".[/TD]
[/TR]
</tbody>[/TABLE]
Last edited: