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
 
That makes a big difference, as some functions used are not available in 2019. Have a look at the green cells for formulas that should work in 2019. In some cases, you'll need to enter the formulas with Ctrl-Shift-Enter (sometimes abbreviated CSE). If you enter the formula normally, confirming it with Enter, you won't see the correct answer. When that happens, click in the formula bar, hit F2 to enter editing mode, and then hit Ctrl-Shift-Enter simultaneously. You should see curly brackets automatically surround the formula indicating it is now an array formula. Also, please update your profile to show Excel 2019 to avoid confusion.
MrExcel_20220803.xlsx
NOPQRST
1DataExcel 365Excel 2019
2666Mode data <650628628confirm with CSE
3702Mode data >=650666666confirm with CSE
4741Min~Max608~799608~799
5678Min~Max of data < 650608~646608~646
6673min~max like (608~646)
7707Lower endpoint of range600
8737Upper endpoint of range700
9729Count of points in range1616
10797Count of points2626
11731
12799
13729
14710
15655
16608
17628
18658
19643
20646
21666
22628
23636
24641
25677
26626
27646
Sheet9
Cell Formulas
RangeFormula
R2R2=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27<Q2))
R3R3=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27>=Q3))
R4:S4R4=TEXT(MIN($N:$N),"0")&"~"&TEXT(MAX($N:$N),"0")
R5R5=TEXT(MIN(FILTER(N:N,N:N<650)),"0")&"~"&TEXT(MAX(FILTER(N:N,N:N<650)),"0")
S2S2=MODE(IF($N$2:$N$27<Q2,$N$2:$N$27))
S3S3=MODE(IF($N$2:$N$27>=Q3,$N$2:$N$27))
S5S5=TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")
S6S6="min~max like (" & TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0") &")"
R9R9=COUNTIFS(N:N,">="&Q7,N:N,"<="&Q8)
S9S9=COUNTIFS(N:N,">="&Q7,N:N,"<="&Q8)
R10R10=COUNT(N:N)
S10S10=COUNT(N:N)
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
That makes a big difference, as some functions used are not available in 2019. Have a look at the green cells for formulas that should work in 2019. In some cases, you'll need to enter the formulas with Ctrl-Shift-Enter (sometimes abbreviated CSE). If you enter the formula normally, confirming it with Enter, you won't see the correct answer. When that happens, click in the formula bar, hit F2 to enter editing mode, and then hit Ctrl-Shift-Enter simultaneously. You should see curly brackets automatically surround the formula indicating it is now an array formula. Also, please update your profile to show Excel 2019 to avoid confusion.
MrExcel_20220803.xlsx
NOPQRST
1DataExcel 365Excel 2019
2666Mode data <650628628confirm with CSE
3702Mode data >=650666666confirm with CSE
4741Min~Max608~799608~799
5678Min~Max of data < 650608~646608~646
6673min~max like (608~646)
7707Lower endpoint of range600
8737Upper endpoint of range700
9729Count of points in range1616
10797Count of points2626
11731
12799
13729
14710
15655
16608
17628
18658
19643
20646
21666
22628
23636
24641
25677
26626
27646
Sheet9
Cell Formulas
RangeFormula
R2R2=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27<Q2))
R3R3=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27>=Q3))
R4:S4R4=TEXT(MIN($N:$N),"0")&"~"&TEXT(MAX($N:$N),"0")
R5R5=TEXT(MIN(FILTER(N:N,N:N<650)),"0")&"~"&TEXT(MAX(FILTER(N:N,N:N<650)),"0")
S2S2=MODE(IF($N$2:$N$27<Q2,$N$2:$N$27))
S3S3=MODE(IF($N$2:$N$27>=Q3,$N$2:$N$27))
S5S5=TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")
S6S6="min~max like (" & TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0") &")"
R9R9=COUNTIFS(N:N,">="&Q7,N:N,"<="&Q8)
S9S9=COUNTIFS(N:N,">="&Q7,N:N,"<="&Q8)
R10R10=COUNT(N:N)
S10S10=COUNT(N:N)
Thanks a lot KRice, May I know what is the meaning for 15,6 and 14,6 in this formula(=TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0"))?
 
Upvote 0
I'm happy to help. See my explanation in post #9 of this thread and let me know if it answers your question about the use of AGGREGATE functions:
 
Upvote 0
I'm happy to help. See my explanation in post #9 of this thread and let me know if it answers your question about the use of AGGREGATE functions:
thank you very much from the provided information. I have another problem. May I know the formula to find out the mode value between the range 600~700?
 
Upvote 0
You'll need a variation of the MODE formula. See the block added (orange cells):
MrExcel_20220803.xlsx
NOPQRST
1DataExcel 365Excel 2019
2666Mode data <650628628confirm with CSE
3702Mode data >=650666666confirm with CSE
4741Range lower limit x>=LL600
5678Range upper limit x<=UL700
6673Mode LL<=x<=UL666confirm with CSE
7707Min~Max608~799608~799
8737Min~Max of data < 650608~646608~646
9729min~max like (608~646)
10797Lower endpoint of range600
11731Upper endpoint of range700
12799Count of points in range1616
13729Count of points2626
14710
15655
16608
17628
18658
19643
20646
21666
22628
23636
24641
25677
26626
27646
Sheet9
Cell Formulas
RangeFormula
R2R2=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27<Q2))
S2S2=MODE(IF($N$2:$N$27<Q2,$N$2:$N$27))
R3R3=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27>=Q3))
S3S3=MODE(IF($N$2:$N$27>=Q3,$N$2:$N$27))
R7:S7R7=TEXT(MIN($N:$N),"0")&"~"&TEXT(MAX($N:$N),"0")
R8R8=TEXT(MIN(FILTER(N:N,N:N<650)),"0")&"~"&TEXT(MAX(FILTER(N:N,N:N<650)),"0")
S6S6=MODE(IF(($N$2:$N$27>=Q4)*($N$2:$N$27<=Q5),$N$2:$N$27))
S8S8=TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")
S9S9="min~max like (" & TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0") &")"
R12R12=COUNTIFS(N:N,">="&Q10,N:N,"<="&Q11)
S12S12=COUNTIFS(N:N,">="&Q10,N:N,"<="&Q11)
R13R13=COUNT(N:N)
S13S13=COUNT(N:N)
 
Upvote 0
You'll need a variation of the MODE formula. See the block added (orange cells):
MrExcel_20220803.xlsx
NOPQRST
1DataExcel 365Excel 2019
2666Mode data <650628628confirm with CSE
3702Mode data >=650666666confirm with CSE
4741Range lower limit x>=LL600
5678Range upper limit x<=UL700
6673Mode LL<=x<=UL666confirm with CSE
7707Min~Max608~799608~799
8737Min~Max of data < 650608~646608~646
9729min~max like (608~646)
10797Lower endpoint of range600
11731Upper endpoint of range700
12799Count of points in range1616
13729Count of points2626
14710
15655
16608
17628
18658
19643
20646
21666
22628
23636
24641
25677
26626
27646
Sheet9
Cell Formulas
RangeFormula
R2R2=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27<Q2))
S2S2=MODE(IF($N$2:$N$27<Q2,$N$2:$N$27))
R3R3=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27>=Q3))
S3S3=MODE(IF($N$2:$N$27>=Q3,$N$2:$N$27))
R7:S7R7=TEXT(MIN($N:$N),"0")&"~"&TEXT(MAX($N:$N),"0")
R8R8=TEXT(MIN(FILTER(N:N,N:N<650)),"0")&"~"&TEXT(MAX(FILTER(N:N,N:N<650)),"0")
S6S6=MODE(IF(($N$2:$N$27>=Q4)*($N$2:$N$27<=Q5),$N$2:$N$27))
S8S8=TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")
S9S9="min~max like (" & TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0") &")"
R12R12=COUNTIFS(N:N,">="&Q10,N:N,"<="&Q11)
S12S12=COUNTIFS(N:N,">="&Q10,N:N,"<="&Q11)
R13R13=COUNT(N:N)
S13S13=COUNT(N:N)
Actually the situation is like this , Every time I select a specific product from the slicer, table below will show how many data points are lie between 650 to 700 and range for pass or fail is the min and max value from the 19 data points. Do u have any ideas for setting the mode formula for this situation which link to the cell in range for pass/fail?
RangeData pointsRange for Pass/failMode value
650~70019652~700

 
Upvote 0
See the peach/purple cells. I'm relying on the input cell under "Range" (cell P10 here) rather than "pass/fail" since the slicer is using that same input. Formulas can return the same information, but generally it's a bad idea to rely on text strings (like 650-700 or 655~678) to perform numeric calculations because you have to extract values from the text strings. Then you have two choices: 1) either stash those values somewhere in helper cells so they can be referenced in other formulas, or 2) carry along the awkward formula components necessary for extracting the values and insert those components every time the values are needed. I used the latter approach to illustrate how the single input in the dark purple cell (P10) is used to return the number of data points, the actual range of data falling within the input limits, the mode, and the average.
MrExcel_20220803.xlsx
NOPQRST
1DataExcel 365Excel 2019
2666Mode data <650628628confirm with CSE
3702Mode data >=650666666confirm with CSE
4741Range lower limit x>=LL600
5678Range upper limit x<=UL700
6673Mode LL<=x<=UL666confirm with CSE
7707
8737RangeData PointsRange for Pass/failMode valueAverage value
9729650-70019652~700
10797650-7007655~678666667.6
11731
12799Min~Max608~799608~799
13729Min~Max of data < 650608~646608~646
14710min~max like (608~646)
15655Lower endpoint of range600
16608Upper endpoint of range700
17628Count of points in range1616
18658Count of points2626
19643
20646
21666
22628
23636
24641
25677
26626
27646
Sheet9
Cell Formulas
RangeFormula
R2R2=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27<Q2))
S2S2=MODE(IF($N$2:$N$27<Q2,$N$2:$N$27))
R3R3=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27>=Q3))
S3S3=MODE(IF($N$2:$N$27>=Q3,$N$2:$N$27))
S6S6=MODE(IF(($N$2:$N$27>=Q4)*($N$2:$N$27<=Q5),$N$2:$N$27))
Q10Q10=SUM(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),1))
R10R10=MIN(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),$N$2:$N$27))&"~"&MAX(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),$N$2:$N$27))
S10S10=MODE(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),$N$2:$N$27))
T10T10=AVERAGE(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),$N$2:$N$27))
R12:S12R12=TEXT(MIN($N:$N),"0")&"~"&TEXT(MAX($N:$N),"0")
R13R13=TEXT(MIN(FILTER(N:N,N:N<650)),"0")&"~"&TEXT(MAX(FILTER(N:N,N:N<650)),"0")
S13S13=TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")
S14S14="min~max like (" & TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0") &")"
R17R17=COUNTIFS(N:N,">="&Q15,N:N,"<="&Q16)
S17S17=COUNTIFS(N:N,">="&Q15,N:N,"<="&Q16)
R18R18=COUNT(N:N)
S18S18=COUNT(N:N)
 
Upvote 0
See the peach/purple cells. I'm relying on the input cell under "Range" (cell P10 here) rather than "pass/fail" since the slicer is using that same input. Formulas can return the same information, but generally it's a bad idea to rely on text strings (like 650-700 or 655~678) to perform numeric calculations because you have to extract values from the text strings. Then you have two choices: 1) either stash those values somewhere in helper cells so they can be referenced in other formulas, or 2) carry along the awkward formula components necessary for extracting the values and insert those components every time the values are needed. I used the latter approach to illustrate how the single input in the dark purple cell (P10) is used to return the number of data points, the actual range of data falling within the input limits, the mode, and the average.
MrExcel_20220803.xlsx
NOPQRST
1DataExcel 365Excel 2019
2666Mode data <650628628confirm with CSE
3702Mode data >=650666666confirm with CSE
4741Range lower limit x>=LL600
5678Range upper limit x<=UL700
6673Mode LL<=x<=UL666confirm with CSE
7707
8737RangeData PointsRange for Pass/failMode valueAverage value
9729650-70019652~700
10797650-7007655~678666667.6
11731
12799Min~Max608~799608~799
13729Min~Max of data < 650608~646608~646
14710min~max like (608~646)
15655Lower endpoint of range600
16608Upper endpoint of range700
17628Count of points in range1616
18658Count of points2626
19643
20646
21666
22628
23636
24641
25677
26626
27646
Sheet9
Cell Formulas
RangeFormula
R2R2=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27<Q2))
S2S2=MODE(IF($N$2:$N$27<Q2,$N$2:$N$27))
R3R3=MODE.SNGL(FILTER($N$2:$N$27,$N$2:$N$27>=Q3))
S3S3=MODE(IF($N$2:$N$27>=Q3,$N$2:$N$27))
S6S6=MODE(IF(($N$2:$N$27>=Q4)*($N$2:$N$27<=Q5),$N$2:$N$27))
Q10Q10=SUM(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),1))
R10R10=MIN(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),$N$2:$N$27))&"~"&MAX(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),$N$2:$N$27))
S10S10=MODE(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),$N$2:$N$27))
T10T10=AVERAGE(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),$N$2:$N$27))
R12:S12R12=TEXT(MIN($N:$N),"0")&"~"&TEXT(MAX($N:$N),"0")
R13R13=TEXT(MIN(FILTER(N:N,N:N<650)),"0")&"~"&TEXT(MAX(FILTER(N:N,N:N<650)),"0")
S13S13=TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")
S14S14="min~max like (" & TEXT(AGGREGATE(15,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0")&"~"&TEXT(AGGREGATE(14,6,(N2:N100)/((N2:N100<650)*(N2:N100<>"")),1),"0") &")"
R17R17=COUNTIFS(N:N,">="&Q15,N:N,"<="&Q16)
S17S17=COUNTIFS(N:N,">="&Q15,N:N,"<="&Q16)
R18R18=COUNT(N:N)
S18S18=COUNT(N:N)
May I know how to get the P10 (650~700) as I noticed there is no 650 and 700 appear in this formula (=SUM(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),1)))?
 
Upvote 0
P10 is the input text. The formula extracts the two numbers shown in P10.
 
Upvote 0
I hope my last post was clear. My understanding is that you are getting summary information from a slicer and it is displayed as shown in your post #16. If that is the case, then to obtain numbers like 650 and 700, you have to do extra work to extract those values from the text string under the "Range" label. That is why I commented:
Formulas can return the same information, but generally it's a bad idea to rely on text strings (like 650-700 or 655~678) to perform numeric calculations because you have to extract values from the text strings.
In this case, extra steps are needed to identify where the hyphen (-) is in the text string, as that separates the two numbers:
SEARCH("-",P10)
Then based on the position of the hyphen, we can take the text to the left of it:
LEFT(P10,SEARCH("-",P10)-1)
...where the -1 means to stop just before reaching the hyphen's position. This results in the text "650".
Then we need to convert this text to an actual value, so I've multiplied by 1, which coerces text that looks like a number to an actual number.
So 1*LEFT(P10,SEARCH("-",P10)-1) delivers the number 650 (or whatever number appears before the hyphen in P10).

The story is similar, but a little more complicated, for extracting 700, or whatever number appears after the hyphen in P10. That's what this part of the formula does:
1*RIGHT(P10,LEN(P10)-SEARCH("-",P10))

Back to my comment about using text strings...the formula for mode shown in post #16 is this:
MODE(IF(($N$2:$N$27>=1*LEFT(P10,SEARCH("-",P10)-1))*($N$2:$N$27<=1*RIGHT(P10,LEN(P10)-SEARCH("-",P10)) ),$N$2:$N$27))
If you hardwired the numbers directly into the formula or simply referred to individual cells where the range limits are found (say Q4 and Q5), the formula would look something like:
MODE(IF(($N$2:$N$27>=650)*($N$2:$N$27<=700),$N$2:$N$27))
or
MODE(IF(($N$2:$N$27>=Q4)*($N$2:$N$27<=Q5),$N$2:$N$27))
So approximately half of the formula is consumed by operations doing nothing more than extracting values from text...values that you may already have somewhere else.
 
Upvote 0

Forum statistics

Threads
1,215,014
Messages
6,122,697
Members
449,092
Latest member
snoom82

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