EXCEL - Multiple Arrays within COUNTIF formula - arrays

Attempting to count:
Named range "STATUS" if the value of the cells equals Reserved, Blocked, Pending OR Archive
AND
Named range "COMPANY" equals Company A, Company B OR Company C.
I'm also counting multiple other criteria, all of the which are working. When I added the array for the Company the formula is no longer counting the Status.
Here is the formula I'm using:
=SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,{"COMPANY A","COMPANY B","COMPANY C"},STATUS,{"Reserved","Blocked","Pending","Archive"})))
Any help is greatly appreciated and thank you in advance!

Try this
=SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,{"COMPANY A";"COMPANY B";"COMPANY C"},STATUS,{"Reserved","Blocked","Pending","Archive"})))
or
=SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,{"COMPANY A","COMPANY B","COMPANY C"},STATUS,{"Reserved";"Blocked";"Pending";"Archive"})))
Note the ; instead of , in arrays. For details on why to use semi-colon instead of comma see this.
If you want to use your formula it should be as follows
=SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,"COMPANY A",STATUS,{"Reserved","Blocked","Pending","Archive"}))) +
SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,"COMPANY B",STATUS,{"Reserved","Blocked","Pending","Archive"}))) +
SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,"COMPANY C",STATUS,{"Reserved","Blocked","Pending","Archive"})))

you can create additional column with all of the conditions you need as if inside an IF condition, e.g.
=(A2>=A19) * ((B2="COMPANY A") + (B2="COMPANY B")))
and then =COUNTIF(ALL_CONDITIONS, ">0")

Related

Excel filter formula for multiple criteria and value in array

I'm trying to filter some information from one table, but I need the criteria to look for some info inside an array. I'll give an example to try to explain what I need:
I need to get everyone from Array1 E2:E4 that is listed on TABLE1 A2:C4 and has Monday and Yes on their respective columns.
Hope that makes sense and that somebody will be able to help me on this one.
Thanks a lot!
Tried using filter formula but I can't make it work with the array as a filter.
What about this, it will give you the required output,
• Formula used in cell G2
=FILTER(A2:A4,(MMULT(--(TRANSPOSE(E2:E4)=A2:A4),ROW(E2:E4)^0)=1)*(B2:B4="Monday")*(C2:C4="Yes"))
Here are other alternatives:
• Formula used in cell I2
=LET(_table,A2:C4,
_name,INDEX(_table,,1),
_day,INDEX(_table,,2),
_include,INDEX(_table,,3),
_array,E2:E4,
x,--BYROW(_name,LAMBDA(a,(SUM(COUNTIFS(a,_array))>0))),
FILTER(_name,(x=1)*(_day="Monday")*(_include="Yes")))
• Formula used in cell K2
=LET(_table,A2:C4,
_name,E2:E4,
_map,MAP(INDEX(_table,,1),LAMBDA(m,IF(SUM(COUNTIF(m,_name))>0,m,""))),
_other,(INDEX(_table,,2)="Monday")*(INDEX(_table,,3)="Yes"),
FILTER(TAKE(_table,,1),(_map<>"")*_other))
I agree with user who mention this place is not for homework, but I know useful information about it.
Microsoft explain how use "AND" into filter in the following link
Basically use * operator, with this info I mimic your homework to return values using filters.
Formula:
=FILTER(A2:C4, (B2:B4=D6) * ( C2:C4=D7),"")
D6 = Monday
D7 = Yes

Array formula is not working to my subsequent entries - filling rest of the entries with respect to the first entry only

Im using an array formula in google sheet as a response to a google form which has an F field that has the first name of a person (say, thomas) and a G field whic is the last name of a person(say, mathew)and E field that has a custom email domain say "test.org" - the result expected is "thomasm_#test.org"
Im applying this array formula to one of my header field which will be given with a header name "UserID".
ArrayFormula(IFS(ROW(A:A)=1, "UserID", LEN(A:A)=0, IFERROR(1/0), LEN(A:A)>0,LOWER(CONCATENATE(SUBSTITUTE(F2," ",""),LEFT(G2,1),"_",E2))))
Applying this formula it will apply to whatever entries i had given in the second row to all subsequent rows.. subsequent entries are not reflecting... Pls help
Hi #richtom welcome to this community!
A few reasons:
concatenate function will not work inside of an arrayfunction as you're expecting, so avoid this.
Another thing is that also here SUBSTITUTE(F2," ",""),LEFT(G2,1),"_",E2), you must use the same rangesize as in the beginning, i.e. A:A... F:F... G:G. the use of F2 will use F2 only in all rows.
So, I recommend the following:
=arrayformula(if(row(F:F)=row(),"UserID",if(F:F="","",if(G:G="","",if(E:E="","",lower(substitute(F:F & left(G:G,1) & "_#" & E:E," ","")))))))

Google Sheets Filtering by 2 separate conditions

I'm trying to create a way to most effectively see who is working at a certain day and block of time. So far, I've created my data lists that have the Name of the reps in A, the day available in B, the reps names again in D, and the blocks of time available in E. I've been trying to use FILTER in order for it to pull based on 2 dropdowns. I've tried using all 3 of these:
=filter(Sheet2!A2:A999,Sheet2!B2:B999=A2,Sheet2!E2:E999=B2)
=FILTER(Sheet2!A2:A,(Sheet2!B1:b=A2)+(Sheet2!B2:B=B2)
=Filter(Filter(Sheet2!A2:A999, Sheet2!B2:B999=A2), Sheet2!B2:B999=B2)
But I can't crack it. The last nested formula seems like it's functioning correctly, except that it's returning a different number of rows each time, so I don't know how to avoid the mismatched range error it gets. To be fair, I'm basically trying to create this from scratch, having known nothing about the FILTER function before saturday. Any ideas on how I can accomplish this with filters would be super helpful.
https://docs.google.com/spreadsheets/d/1WhBSQy4OZFtJvheNHd5ZfIRvcDxvUb-WhdY0mUci3O0/edit?usp=sharing
I have found this function =filter(Sheet2!A2:A136, Sheet2!B2:B136 =G2) on your sheet and based on that I have added the filter for the time, and works.
The working condition is:
=filter(Sheet2!A2:A136, Sheet2!B2:B136 =A2, Sheet2!E2:E136 = B2)
Based on the FILTER documentation:
FILTER(range, condition1, [condition2, ...])
first, in your data validation fix 7-7:30 to 7-730. then use this:
=ARRAYFORMULA(UNIQUE(QUERY(TO_TEXT({Sheet2!A2:B; Sheet2!D2:E}),
"select Col1 where Col2 matches '"&TEXTJOIN("|", 1, A2:B2)&"'")))

AT NEW with substring access?

I have a solution that includes a LOOP which I would like to spare. So I wonder, whether you know a better way to do this.
My goal is to loop through an internal, alphabetically sorted standard table. This table has two columns: a name and a table, let's call it subtable. For every subtable I want to do some stuff (open an xml page in my xml framework).
Now, every subtable has a corresponding name. I want to group the subtables according to the first letter of this name (meaning, put the pages of these subtables on one main page -one main page for every character-). By grouping of subtables I mean, while looping through the table, I want to deal with the subtables differently according to the first letter of their name.
So far I came up with the following solution:
TYPES: BEGIN OF l_str_tables_extra,
first_letter(1) TYPE c,
name TYPE string,
subtable TYPE REF TO if_table,
END OF l_str_tables_extra.
DATA: ls_tables_extra TYPE l_str_tables_extra.
DATA: lt_tables_extra TYPE TABLE OF l_str_tables_extra.
FIELD-SYMBOLS: <ls_tables> TYPE str_table."Like LINE OF lt_tables.
FIELD-SYMBOLS: <ls_tables_extra> TYPE l_str_tables_extra.
*"--- PROCESSING LOGIC ------------------------------------------------
SORT lt_tables ASCENDING BY name.
"Add first letter column in order to use 'at new' later on
"This is the loop I would like to spare
LOOP AT lt_tables ASSIGNING <ls_tables>.
ls_tables_extra-first_letter = <ls_tables>-name+0(1). "new column
ls_tables_extra-name = <ls_tables>-name.
ls_tables_extra-subtable = <ls_tables>-subtable.
APPEND ls_tables_extra TO lt_tables_extra.
ENDLOOP.
LOOP AT lt_tables_extra ASSIGNING <ls_tables_extra>.
AT NEW first_letter.
"Do something with subtables with same first_letter.
ENDAT.
ENDLOOP.
I wish I could use
AT NEW name+0(1)
instead of
AT NEW first_letter
, but offsets and lengths are not allowed.
You see, I have to inlcude this first loop to add another column to my table which is kind of unnecessary because there is no new info gained.
In addition, I am interested in other solutions because I get into trouble with the framework later on for different reasons. A different way to do this might help me out there, too.
I am happy to hear any thoughts about this! I could not find anything related to this here on stackoverflow, but I might have used not optimal search terms ;)
Maybe the GROUP BY addition on LOOP could help you in this case:
LOOP AT i_tables
INTO DATA(wa_line)
" group lines by condition
GROUP BY (
" substring() because normal offset would be evaluated immediately
name = substring( val = wa_line-name len = 1 )
) INTO DATA(o_group).
" begin of loop over all tables starting with o_group-name(1)
" loop over group object which contains
LOOP AT GROUP o_group
ASSIGNING FIELD-SYMBOL(<fs_table>).
" <fs_table> contains your table
ENDLOOP.
" end of loop
ENDLOOP.
why not using a IF comparison?
data: lf_prev_first_letter(1) type c.
loop at lt_table assigning <ls_table>.
if <ls_table>-name(1) <> lf_prev_first_letter. "=AT NEW
"do something
lf_prev_first_letter = <ls_table>-name(1).
endif.
endloop.

salesforce.com Formula : How to check if the Record is new

I have to calculate the agreement value for my new record .Assuming that agreement value is ending_days - begining_days. I have put this formula in my object.
IF(Beginning_c <> Ending_c,Ending_c-Beginning_c,0).
I have two questions related to this
1: What is the agreement value ?, Am i correct in assuming what i have assumed or does it some specific other meaning?
2: I have to create an agreement value for new records only. So, should i take care of this fact in my IF condition For example : should my IF code look something like this
IF (AND(//somehow check if the record is new,Beginning_c <> Ending_c),Ending_c-Beginning_c,0)
First, if Beginning__c == Ending__c then Ending__c-Beginning__c is already 0 so your formula does not need IF at all.
Second, formula is evaluated every time its referenced in SOQL, if you want a once-off calculation you should use before insert trigger or a workflow and store result in regular field.
To answer part 2 of your question. Use the function ISNEW() in you formula.
So your complete formula would be:
IF (AND(ISNEW(),Beginning_c <> Ending_c),Ending_c-Beginning_c,0)

Resources