MODE FORMULA FOR MULTIPLE CONDITIONS??

michellesssme

New Member
Joined
Aug 5, 2022
Messages
20
Office Version
  1. 2021
Platform
  1. Windows
Based on the Data column,
May I know the formula for both conditions (1. & 2.) by using MODE & IF Formula?
1. mode value for condition <650
2. mode value for condition >=650

3. May I know how to insert condition (<650) in the formula (=TEXT(MIN($N:$N),"0")&"~"&TEXT(MAX($N:$N),"0")?
4. How to write the formula to count how many data points fall on the specific range like from 600 to 700?

Data
666
702
741
678
673
707
737
729
797
731
799
729
710
655
608
628
658
643
646
666
628
636
641
677
626
646
 
Thanks a lot for the guidance above.
I have another question. May I know what is the formula for automatically detect the highest number in column BH and show in cell BN (69) and the respective range will be along in cell BO (650~700)?
 

Attachments

  • example 2.PNG
    example 2.PNG
    27.2 KB · Views: 4
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Please see my comments in posts #17 and 20 where I mention the inefficiency in taking numeric values and incorporating them into text expressions, and then later extracting those same numeric values from the text expressions for use in subsequent computations. Since you have the source data (originally shown in the range N2:N27) and you seem to be interesting in grouping the data set into bins, is there some reason why using the FREQUENCY function would not work for you? In the example below, the user specifies the thresholds for bins. As one moves down the bin threshold column, each bin threshold and the one immediately above it create a range that the data set is compared to. A count of the number of points falling within each range is produced by the FREQUENCY function (you will need to enter the FREQUENCY formula using Ctrl-Shift-Enter).

I do not understand the purpose or value added by determining the min and max, or the mode and average of the values within each range; however, if that is needed, then the methods described earlier will do that. Another approach that relies directly on the Bin Thresholds is shown below. Also shown is how the FREQUENCY function can be used with other functions to produce the results you asked about (green cells). Also note that I've included the MODE.MULT function in column X. Up until now, the assumption has been that your data will be unimodal (i.e., it has one mode), or if you have multiple modes, only one needs to be returned. If that is not the case, you may want to use MODE.MULT to return all of the modes. In this case, there are four modes (each appears twice in the data set).

I've introduced a named variable "BigNum" to allow some formulas to correctly accept source data in the upper bin where there is no upper bound on the range. The value for BigNum is defined in Formula > Name Manager with =9.99999999999999E+307 in the "Refers to:" field.
MrExcel_20220803.xlsx
PQRSTUVWXYZ
20Bin thresholdsRange (a < x <= b)Data Points in range (frequency)Min Data Point in Bin RangeMax Data Point in Bin RangeModeAverageMulti-ModalMax frequencyRange
216000~6000    6669600~650
22650600~6509608646628.0633.6729
23700650~7007655678666.0667.6628
24750700~7508702741729.0723.3646
25800750~8002797799 798.0
26850800~8500    
27850~0    
Sheet9
Cell Formulas
RangeFormula
R21:R27R21=FREQUENCY($N$2:$N$27,$P$21:$P$26)
S21:S27S21=IFERROR(AGGREGATE(15,6,($N$2:$N$27)/(($N$2:$N$27>N($P20))*($N$2:$N$27<=MIN($P21,BigNum))),1),"")
T21:T27T21=IFERROR(AGGREGATE(14,6,($N$2:$N$27)/(($N$2:$N$27>N($P20))*($N$2:$N$27<=MIN($P21,BigNum))),1),"")
U21:U27U21=IFERROR(MODE(IF(($N$2:$N$27>N($P20))*($N$2:$N$27<=MIN($P21,BigNum)),$N$2:$N$27)),"")
V21:V27V21=IFERROR(AVERAGE(IF(($N$2:$N$27>N($P20))*($N$2:$N$27<=MIN($P21,BigNum)),$N$2:$N$27)),"")
X21:X24X21=MODE.MULT($N$2:$N$27)
Y21Y21=MAX(FREQUENCY($N$2:$N$27,$P$21:$P$26))
Z21Z21=INDEX($Q$21:$Q$27,MATCH(Y21,$R$21:$R$27,0))
Q21:Q27Q21=N(P20)&"~"&P21
Dynamic array formulas.

Source data:
MrExcel_20220803.xlsx
N
1Data
2666
3702
4741
5678
6673
7707
8737
9729
10797
11731
12799
13729
14710
15655
16608
17628
18658
19643
20646
21666
22628
23636
24641
25677
26626
27646
Sheet9
 
Upvote 0
Thanks for the comments and guidance, I will consider about it. May I know what is the formula for separate the digit number from the first cell to the 1, 4.7 and 5.2?

1 4.7 5.2
1​
4.7​
5.2​
2 5.4 6.1
3 4.7 5.9
 
Upvote 0
There are multiple ways to do that, If for some reason you don't have direct access to the source numbers and are dealing with text strings, and you wanted a formula for this, I would use FILTERXML. In the formula below, I know the delimiter is a single space (because I typed it). It is conceivable that what appears to be a space is not an actual space, in which case you would need to interrogate the text string to determine what the delimiter character is, and then specify that character in the SUBSTITUTE function where " " currently appears:
MrExcel_20220803.xlsx
ABCD
291 4.7 5.214.75.2
302 5.4 6.125.46.1
313 4.7 5.934.75.9
Sheet9
Cell Formulas
RangeFormula
B29:D31B29=TRANSPOSE(FILTERXML( "<t><s>" & SUBSTITUTE( A29, " ", "</s><s>" ) & "</s></t>", "//s" ))
Dynamic array formulas.

If this is to be done only occasionally, you might opt to use the Text to Columns functionality in Excel. Alternatively, you could create a Power Query script to perform this extraction.
 
Upvote 0
There are multiple ways to do that, If for some reason you don't have direct access to the source numbers and are dealing with text strings, and you wanted a formula for this, I would use FILTERXML. In the formula below, I know the delimiter is a single space (because I typed it). It is conceivable that what appears to be a space is not an actual space, in which case you would need to interrogate the text string to determine what the delimiter character is, and then specify that character in the SUBSTITUTE function where " " currently appears:
MrExcel_20220803.xlsx
ABCD
291 4.7 5.214.75.2
302 5.4 6.125.46.1
313 4.7 5.934.75.9
Sheet9
Cell Formulas
RangeFormula
B29:D31B29=TRANSPOSE(FILTERXML( "<t><s>" & SUBSTITUTE( A29, " ", "</s><s>" ) & "</s></t>", "//s" ))
Dynamic array formulas.

If this is to be done only occasionally, you might opt to use the Text to Columns functionality in Excel. Alternatively, you could create a Power Query script to perform this extraction.
TQ.
This is my another question about Excel, Kindly informed that my Excel version is 2021.
It shows Fail status after I apply this formula, but suppose the status should be Pass (because all type A readings are more than equal to 4). May I know is there any mistakes from the formula?
 

Attachments

  • QUESTION 2.PNG
    QUESTION 2.PNG
    26.9 KB · Views: 4
Upvote 0
It isn't clear what you are trying to do. As written, your formula:
Excel Formula:
=IF(AND(Table1[[#Headers],[TYPE]]="A",Table1[[#Headers],[Reading]]>=4),"Pass","Fail")
...is equivalent to:
Excel Formula:
=IF(AND("TYPE"="A","Reading">=4),"Pass","Fail")
which will never produce an answer of "Pass" since neither of the conditions is TRUE.. The AND function will always return FALSE. So the first issue is that your structured references include [#Headers], which is why your expression reduces to what I've shown above.
You could change the formula to:
Excel Formula:
=IF(AND(Table1[TYPE]="A",Table1[Reading]>=4),"Pass","Fail")
which causes the AND function to look at two arrays of TRUEs and FALSEs, but if any single item is FALSE, the formula evaluates to FALSE (see item #3 below). The AND function produces only a single result, not an array.

But what are you trying to evaluate?
  1. Do you want 8 answers...one for every pair of type-result?
  2. Do you want to know if all 4 "A" types have results >=4...so you want a singe answer for only the A's?
  3. Do you want to know if collectively all 8 rows satisfy the condition (so a single instance of a type not being an "A" or a result <4 would be sufficient to produce a single answer of FALSE?
 
Upvote 0
It isn't clear what you are trying to do. As written, your formula:
Excel Formula:
=IF(AND(Table1[[#Headers],[TYPE]]="A",Table1[[#Headers],[Reading]]>=4),"Pass","Fail")
...is equivalent to:
Excel Formula:
=IF(AND("TYPE"="A","Reading">=4),"Pass","Fail")
which will never produce an answer of "Pass" since neither of the conditions is TRUE.. The AND function will always return FALSE. So the first issue is that your structured references include [#Headers], which is why your expression reduces to what I've shown above.
You could change the formula to:
Excel Formula:
=IF(AND(Table1[TYPE]="A",Table1[Reading]>=4),"Pass","Fail")
which causes the AND function to look at two arrays of TRUEs and FALSEs, but if any single item is FALSE, the formula evaluates to FALSE (see item #3 below). The AND function produces only a single result, not an array.

But what are you trying to evaluate?
  1. Do you want 8 answers...one for every pair of type-result?
  2. Do you want to know if all 4 "A" types have results >=4...so you want a singe answer for only the A's?
  3. Do you want to know if collectively all 8 rows satisfy the condition (so a single instance of a type not being an "A" or a result <4 would be sufficient to produce a single answer of FALSE?
I want a status (PASS/FAIL) for each TYPE
if [TYPE]="A" and [Readings]>= 4 then "pass" else "fail"
if [TYPE]="B" and [Readings]>= 4 then "pass" else "fail"
Am I stated clearly?
 
Upvote 0
No, that's not entirely clear. Why do you want to put the "Type" in the expression? Are there only two types, A or B?...or is there some possibility that three or more types are present?
Based on what you've described, why wouldn't this work:
Excel Formula:
=IF(Table1[@Readings]>=4,"Pass","Fail")
 
Upvote 0
No, that's not entirely clear. Why do you want to put the "Type" in the expression? Are there only two types, A or B?...or is there some possibility that three or more types are present?
Based on what you've described, why wouldn't this work:
Excel Formula:
=IF(Table1[@Readings]>=4,"Pass","Fail")
thanks again for the provided formula.
I have another question.
May I know what is the formula to make the yellow cell show 9 (Column No.) and it is clickable (I want to make it clickable as the table is in different sheet)?
*it shows 9 as the reading for No.9 is less than 2.
 

Attachments

  • 27_8.PNG
    27_8.PNG
    18.4 KB · Views: 4
Upvote 0
I'm not sure what you want to do. Do you want a formula to return the value in the [No] column if the value in the [readings] column is less than 2? What do you want to see if multiple values in the [readings] column are less than 2? A formula will return the results automatically, so no further user interaction would be necessary. What does "clickable" mean?
 
Upvote 0

Forum statistics

Threads
1,215,659
Messages
6,126,074
Members
449,286
Latest member
Lantern

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top