Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Google Sheets - Array Formula that searches each row and returns a cell value based on conditions

$
0
0

My data contains traffic source data from Google Analytics, grouped by customer. For each row, there is a TRANSPOSE(ARRAYFORMULA( function that fills a horizontal array of values from another sheet. Any customers in the source sheet that have multiple rows with different values for traffic source will have an array of two or more values.

enter image description here

The formula I need is in column B. The formula I have so far is:

=ARRAYFORMULA(IF(D2:D="",C2:C,IF(COUNTIF($C:$Z,"Affiliate")>0,"Affiliate","-")))

The required output is an array that returns a value of source based on the condition set in the COUNTIF part of the formula. In this case I want "Affiliate" to be returned if it is present in the corresponding row. If it is not present, but "Referral" is present, return "Referral", otherwise return "-". Currently the formula returns "Affiliate" if it is present anywhere in the $C:$Z array, and is therefore not row-based.

Is there a way to change the array formula to search each row independently and return values based on the defined conditions?

Link to sample data with desired output

Edit: included link to sample data with required output. Also changed required output to include multiple values:

In this case I want "Affiliate" to be returned if it is present in the corresponding row. If it is not present, but "Referral" is present, return "Referral", otherwise return "-". Currently the formula returns "Affiliate" if it is present anywhere in the $C:$Z array, and is therefore not row-based.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>