so I used this array formula with INDEX MATCH:
{=INDEX(ENTRIES!$F$4:$F$28;MATCH(C4&F4&G4;ENTRIES!$C$4:$C$28&ENTRIES!$G$4:$G$28&ENTRIES!$H$4:$H$28;0))}
Here is the thing, I was trying to display the price of the "entries" sheet on the "sales" sheet, the problem comes up when there are different prices for one "Code" or product over time. I tried to solve it with an Index Match formula (above) that matches the price of the code (product) with the month and the year but it doesn't assign the price or any value on the months between the updates of the price. see picture
example: for month 6 it should assign the price of month 5 because there is not any update or change. and the same for month 9 it should be the same e of the month 8 for that product. How can I do that?
Looks to me like it's throwing those errors because it won't be able to find these months. In all cases these months are missing, at least with your data, you could tell the formula to pick the maximum row from the data that is below or equal to your search month using MAX()
Furthermore, matching multiple criteria through concatenating cells and columns can get tricky once numeric values/dates are involves and could throw back wrong/unexpected results. Try something along these lines instead:
MATCH(1,((Criteria1)*(Criteria2)*(Criteria3))...
So the whole thing would look like:
=INDEX(ENTRIES!$F$1:$F$28;MAX(((ENTRIES!$C$4:$C$28=C4)*(ENTRIES!$G$4:$G$28<=G4)*(ENTRIES!$H$4:$H$28=H4)*ROW(ENTRIES!$F$4:$F$28))))
Entered through CtrlShiftEnter
#JVDV answer was helpful, but it didn't work for me because it gives me a higher value instead of the latest price for the last month known not the next one.
Anyway looking at your formula, I finally came up with this:
{=IFERROR((INDEX(ENTRIES!$F$4:$F$28;MATCH(C8&J8&K8;ENTRIES!$C$4:$C$28&ENTRIES!$G$4:$G$28&ENTRIES!$H$4:$H$28;0)));INDEX(ENTRIES!$F$4:$F$28;MATCH(1;(ENTRIES!$C$4:$C$28=C8)*(ENTRIES!$G$4:$G$28=J8-1)*(ENTRIES!$H$4:$H$28=K8);0)))}
The first part is my original formula but now when it throws an error applies the second INDEX which finds the price of the month before the month with no price in the data. Of course, it's isn't perfect either because I have to "update" the price at least every two months.
I tried another way with a <= sign but it didn't work either.
Related
I would like to get a count on the total number of lessons of a specific length given within a specific date range.
I can figure out how to get the number of a specific type of lesson on a specific day with something like in:
=countifs(INDEX($E:$V,,MATCH($A8,$E$1:$V$1,1)),"=30")
But I can't figure out how to to find all of the values for say Dates <=A8 (for row 8), or dates >A8 & <=A9 (for row 9).
I am looking to get the data to output like the yellow section.
In Excel:
=countifs(INDEX($E:$V,,MATCH($A8,$E$1:$V$1,1)):INDEX($E:$V,,IFERROR(MATCH($A9,$E$1:$V$1,1)-1,COLUMN($V$1))),"=30")
But note, this will not work in Google Sheets.
I'm not sure it is the most elegant. My solution was to create a hidden column (Now E:E) for the to calculate the days between the A column dates.
Example for cell E9
=SUMPRODUCT(($F$1:$W$1>A8)*($F$1:$W$1<A9))
This returned a number of days between days A7 and A8.
I then modified Scott Craner's formula to this (Example for cell B9):
=COUNTIFS(INDEX($F:$W,,MATCH($A9-$E9,$F$1:$W$1,1)):INDEX($F:$W,,IFERROR(MATCH($A9,$F$1:$W$1,),COLUMN($W$1))),"=30")
Remember now, that after adding a column my dates shifted from E1:V1 to F1:W1
These two steps solved my issue with double counting on certain dates.
Lastly, I went back and tested this with Google Sheets and it does now appear that it will also work with Google Sheets.
I have a large spreadsheet containing job information. I am trying to make a "Job Count by Month" field, and it doesn't pull correctly.
My Job Info is all located in a sheet called "3PL Jobs". I have a hidden sheet titled "Under The Hood" which contains a table of months next to their names (i.e. 'Under The Hood'!E2:E13 is a column of numbers and the F column has the corresponding "January","February", etc.
I've made a cell with a dropdown list of the months (pulling from the Under The Hood sheet) and in the cell directly to the right I want it to output the number of completed jobs.
I got this working with the dropdown month list being just a simple list of numbers and not the name, but it looks awful so I was hoping to use an index match to be able to use the name.
This is the code that worked with a list of month numbers, using I19 as the entry cell for the month number
=COUNTIFS(ARRAYFORMULA(MONTH('3PL Jobs'!C3:C)),I19,'3PL Jobs'!AR3:AR,"COMPLETE")
This is the code I've tried to include to index/match the month name (this in theory should just output the month number based on the name selected in I18, but it outputs "8" no matter what is selected)
=arrayformula(index('Under The Hood'!E2:E13,MATCH(I18,'Under The Hood'!F2:F13),1))
I'm sure I'm missing something simple, but this is driving me nuts!
to turn month name into month number all you need is:
=MONTH(I18&1)
i want to know the percent of males in the ER (emergency room) during days that i defined as over crowded days.
i have a DF named eda with rows repesenting each entry to the ER. a certain column states if the entry occurred in an over crowded day (1 means over crowded) and a certain column states the gender of the person who entered.
so far i managed to get a series of over crowded days as index and a sub-index representing gender and the number of entries in that gender.
i used this code :
eda[eda.over_crowd==1].groupby(eda[eda.over_crowd==1].index.date).gender.value_counts()
and got the following result:
my question is, what is the most 'pandas-ian' way to get the percent of males\females in general. or, how to continue from the point i stopped?
as can be shown in the bottom of the screenshot, when i iterate over the elements, each value is the male of female consecutively. i want to iterate over dates so i could somehow write a more clean loop that will produce another column of male percentage.
i found a pretty elegant solution. i'm sure there are more, but maybe it can help someone else.
so i defined a multi-index series with all dates and counts of females and males. then used .loc to operate on each count of all dates to get percentage of males at each day. finally i just extract only the days that apply for over_crowd==1.
temp=eda.groupby(eda.index.date).gender.value_counts()
crowding['male_percent']=np.divide(100*temp.loc[:,1],temp.loc[:,2]+temp.loc[:,1])
crowding.male_percent[crowding.over_crowd==1]
I am trying to get a count of all Unique values listed in Col A, by state and within a date range, for example all records up to the end of April 2018.
I am able to get the count of Unique values by state (result is 2) with the below formula:
{=SUMPRODUCT(1*(FREQUENCY(IF($C$2:$C$14=F10,MATCH($A$2:$A$14,$A$2:$A$14,0)),ROW($A$2:$A$14)-ROW($A$2))>0))}
but I am unable to get the IF function to work with EDATE. I tried the following but I'm getting 0 as the result. The result should be 1.
{=SUMPRODUCT(1*(FREQUENCY(IF(D2:D14="<"&EDATE(G1,1),IF($C$2:$C$14=F10,MATCH($A$2:$A$14,$A$2:$A$14,0))),ROW($A$2:$A$14)-ROW($A$2))>0))}
I am unable to use Pivot as I need to include date range filter. Could someone please look at my code and tell me what I'm doing wrong? I am using CSE with my formulas. Thankyou!
I managed to work it out. EDATE wasn't working so I entered the Month date in cell:G1 then referenced it in the IF formula using "<=" eg: IF(D2:D14<=G1).
Whole array formula is:
`{=SUMPRODUCT(1*(FREQUENCY(IF(D2:D14<=G1,IF($C$2:$C$14=F10,MATCH($A$2:$A$14,$A$2:$A$14,0))),ROW($A$2:$A$14)-ROW($A$2))>0))}
I now receive the correct count of 1, though I have to ensure I have entered the last day of the Month in G1. State is referenced in F10 and count of unique values is in Column A.
My full data set is sourced from multiple documents over 5000 rows each and growing daily so my workbook is quite slow to calculate over 1000 array formulas... but it works!
If anyone knows of a faster (possibly non-array) formula, I would appreciate the advice! Thanks!
Imagine rows A2:A11 = name of customer, Columns B1:AE1 = days of the month.
To make it easy:
Daily, we tally if customers purchase (quantity) and separate them with a + to get the total of that day purchase. (example: on 2nd day of the month (C2:C5)
Abe =44+54+10
John =22+10+40
Sara =40
Mary=10+10
Also we need to count total “sales cases” of the whole day (in the above example it is 3+3+1+2)= 9 to show in the last row of the day. (B12 in this example)
The logic is something like
=SUMPRODUCT(LEN(FORMULATEXT(C2:C5))-LEN(SUBSTITUTE(FORMULATEXT(C2:C5),"+","")))
But I’m getting NA.
reminder: when there are no "+" signs & the value is more than zero, it should count as 1.
help?
There is a trick to do this, which might end up a bit convoluted to achieve the end result you want
First, define a new name in Name Manager (in the Formula menu bar)
Name: FormulaText
Refers to: =GET.CELL(6,OFFSET(INDIRECT("RC",FALSE),0,-1))
Now if you have a formula in cell B3 of =10+20+30 enter =FormulaText in cell C3 and you will get the text version of the formula
You can now count + symbols in that formula using =LEN(C3)-LEN(SUBSTITUTE(C3,"+",""))
In your specific circumstances, I would offset all of this to the right of your spreadsheet, say by 35 columns, in which case you will need to change the definition of FormulaText accordingly.
A fair bit of set-up work, but the result should work automagically.