Same inputs into the frequency function results in different outputs - excel-formula

Most of the information is contained in the attached photo of my excel sheet. There is a breakdown of the issue there. I've narrowed down the problem to the cells highlighted in blue. Please let me know if you know what is going on here. Thank you!
I don't think I explained the frequency equation function well in the photo so here goes another try: With how I have it typed out, the frequency function should output one number for each cell it is referencing (then 1 extra value of 0 at the end that can be ignored in this use case). For the first occurrence of each number, the frequency function should output how many times that number appears in the referenced cells. For each occurrence of that number afterwards, the frequency function should output 0.
Picture showing the problem

Related

Is there a way to count the value of a cell under the criteria in Excel?

I've been toying with this problem for some time but no matter how hard I try, I can't wrap my head around the syntax of a command.
Screenshot of Spreadsheet:
First thing's first. The layout of this spreadsheet can't be changed in any way, making this problem a whole lot more difficult to solve. I've added a screenshot above of what the spreadsheet looks like at the moment. It is currently just a test-sheet as the master-sheet is having real data inputted into it.
So the first problem is searching the array "D:H" for the shot listed in the "I" column. For example, I want to count how many times "Vodka" appears in the array (D:H).
The second problem is I then want to sum each number contained in the cell below the criteria. Following the same example, given the criteria "Vodka" (I4), I want to be able to sum all of the cells under any cell containing the word "Vodka".
The third problem is then to multiply it by the "Amount Sold". Once again, following the same example, I would multiply it by the cells "C5" and "C9" as both of the cocktails have a shot of vodka in them.
The last problem really wraps it all up in a tight little bow. All of this will need to be adaptable to adding, removing and changing cocktails to this list, as well as the shots that are in them and the shots that are being searched.
Again, this is all test information as I don't feel as though I should be putting out anything involving my workplace.
Any help on this would be greatly appreciated.
Count amount of vodka in D:H
=COUNTIF(D4:H13, "Vodka")
Sum of all Vodka
=SUMIF(D5:H5,"Vodka", D4:H4)
Instead of Hard-coding "Vodka" in the cell you should use reference to the cells. This makes expanding the table easier
If you have the value the last multiplication is no problem.

A cell containing the INDEX function is returning the incorrect values

I have the following formula within a cell:
=D26-($L26*$F$3*$E$4)+INDEX($A$1:$Z$500,ROW(D27)-$S$3,18)
It is returning 0, HOWEVER this is not the expected result. When I check the values of the individual terms by copy/pasting them separately into different cells here's what I get:
=D26-($L26*$F$3*$E$4)
returns 300, which is the expected value, and
=INDEX($A$1:$Z$500,ROW(D27)-$S$3,18)
returns 0, which is the expected value.
Why on earth does adding these two terms not return 300 as expected?
As some background, this is an inventory model that adjusts daily inventory based on yesterday's sales and any inventory that has arrived. The first two terms, D26-($L26*$F$3*$E$4), subtract yesterday's sales. The last term, INDEX($A$1:$Z$500,ROW(D27)-$S$3,18), looks back a certain number of days from the current row in order to add any inventory that is scheduled to arrive today. In this case, $S$3 defines lookback period (i.e. the delay between ordering inventory and receiving it).
Ideally, I want to just fill down =D26-($L26*$F$3*$E$4)+INDEX($A$1:$Z$500,ROW(D26)-$S$3,18) for the entire year (365 rows). However, the formula typically works for the first row, but then breaks when I try to fill down. It's not an issue with non-referenced cells. I've tested the individual terms for cells many rows down and they return the expected values. It's just when combining the terms or filling down, I can't seem to get the desired result.
Any guidance would be much appreciated.
I turned out that the cells referenced by the INDEX function contained the INDIRECT function. Eliminating the INDIRECT function got rid of the problem, and I'm getting the values expected now.

Adding X to end of string with exactly 7 characters (not including commas)

'=IF(LEN(A1)<7,A1,IF(LEN(A1)=7,A1&"X",IF(LEN(TRIM(LEFT(A1,IFERROR(FIND(",",A1)-1,0))))=7,TRIM(LEFT(A1,IFERROR(FIND(",",A1)-1,0)))&"X",TRIM(LEFT(A1,IFERROR(FIND(",",A1)-1,A1))))))
I'm using the above code for the following screenshot.
picture
The inputs in column A have had the proper output in Column C using the formula (Thanks cybernetic.nomad) however for the entry in A6, I am getting an error for the output in C6. (The proper output should be AB123456)
There may be a more elegant way to do this, but this seems to get you what you want:
=IF(LEN(A1)<7,A1,IF(LEN(A1)=7,A1&"X",IF(LEN(TRIM(LEFT(A1,IFERROR(FIND(",",A1)-1,0))))=7,TRIM(LEFT(A1,IFERROR(FIND(",",A1)-1,0)))&"X",TRIM(LEFT(A1,IFERROR(FIND(",",A1)-1,A1))))))
Note 1: I assumed numbers with fewer than seven digits stay the same
Edit: Updated formula, but not screen cap

Countif criteria and range are time values, excel 2016

I am using Excel for Mac 2016.
I would like to count number of occurrences of time values e.g., 5:00pm in a column (A1:A100000). I would like to count the number of occurrences according to time value criteria in a different smaller column e.g., (B1:B10), which are also times. So I am matching time with time. For each row of the smaller column, I have tried the following:
=COUNTIF(A1:A100000,B1), which returns 0.
=COUNTIF(A1:A100000,"="&B1), which returns 0.
=COUNTIF(A1:A100000,">="&B1), which funnily enough, returns an actual number of occurrences, but is incorrect because I only want it to equal (B3), not be greater than.
Even when I hard code it in:
=COUNTIF(A1:A100000,">=5:00") works, =COUNTIF(A1:A100000,"=5:00") does not.
Because the time values in (B1:B10) are in serial form, e.g., 5:00pm, 6:00pm etc, even when I try:
=COUNTIFS(A1:A100000,">="&B1,A1:A100000,"<"&B2), it doesn't seem to return a correct value.
It does not seem to matter whether I have the range and/or formatted as Time, or General, nothing works! I'm sure it must be something simple that I am missing.
ok, so here is the ACTUAL formula, which looks nothing like the simplified one above. Basic COUNTIFS with Named ranges, and criteria. I have also uploaded a link to a screen shot of formula, and sample file.
=COUNTIFS(Appointment_date,">="&$C$5,Appointment_date,"<="&$C$6,Client_Name,"?*",Status,"Attended; ",Location,"*Richmond",Appointment_Day,C$9,Appointment_time,$B12)/$C$7
Screen shot:
https://drive.google.com/file/d/0B_m00iNatJANMWVuWGdLem5Vb1U/view?usp=sharing
Sample of file:
https://drive.google.com/open?id=0B_m00iNatJANMnE0UXZyUTctYk0
The real problem appears to be in the formula's inability to recognise specific times in the "Appointment time" column. I have outlined specifics within the document.
Thanks so much!

Identify similar entries based on two criteria

I'm trying identify different status of a product for same colour by using the below formula
=IF(B6&J6=B5&J5,IF(OR(B6&J6&L6=B5&J5&L5,B6&J6&L6=B7&J7&L7),"True","False"),"True")
Result
Expected Result
However, unable to achieve the expected result. I completely lost here kindly lend me a hand :)
Here is a possible answer. Count how many times the most common status (Seasonal) occurs for the current product and colour, then count how many times the status in the current row occurs. If the counts are the same, then this is the most common status so set the result to TRUE, otherwise FALSE.
=COUNTIFS($A$2:$A$20,A2,$B$2:$B$20,B2,$C$2:$C$20,C2)=MAX(COUNTIFS($A$2:$A$20,A2,$B$2:$B$20,B2,$C$2:$C$20,$C$2:$C$20))
Must be entered as an array formula using CtrlShiftEnter
or you can try
=COUNTIFS($A$2:$A$20,A2,$B$2:$B$20,B2,$C$2:$C$20,C2)=AGGREGATE(14,0,COUNTIFS($A$2:$A$20,A2,$B$2:$B$20,B2,$C$2:$C$20,$C$2:$C$20),1)
entered as a normal formula.
Here is a screen shot using your specified columns

Resources