Formula help

Stef9910

Board Regular
Joined
Nov 2, 2022
Messages
72
Office Version
  1. 2010
Platform
  1. Windows
Hello wonderful people of this forum,

I am working on my last formula for my workbook ( well i hope its my last formula),

Without creating a minisheet is anyone able to see where I am going wrong,

The formula i am working on is
=IF($AD$400="", COUNTIFS($D$15:$D$300, AG13, $H$15:$H$300, "Scheduled"), IF($AD$400<>"", COUNTIFS($AG$15:$AG$300, $BC$3, $D$15:$D$300, AG13, $H$15:$H$300, "Scheduled", $D$15:$D$300, $AD$400), COUNTIFS($D$15:$D$300, AG13, $H$15:$H$300, "Scheduled")))

I would like the cell this formula is in to display the total if there is no selection in AD400.

d15:d300 contains the regions.
h15:h300 contains the type (scheduled or unscheduled)
ag15:ag300 contains conditional formatted cells with either a 1 or 2 in it.
bc3 contains the 1
ag13 refers to the date

i could do a minisheet, but the workbook is massive and would take awhile to redact sensitive information.

If anyone is able to see where or what i need to change in the above formula to make the total display when there is no selection in AD400, that would be amazing.

Thankyou for time and any help will be greatly appreciated.

Thanks Stefan
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
@Stef9910 , you don't need to sanitize your entire data. just what needs to be enough for the forum to workwith.
Hide columns not in the calculation. Change Regions and other text to A,B,C,D. Numbers and dates can stay the same.
You only need to copy 4 or 5 rows. So, only change 4 or 5 rows.
 
Upvote 1
IF($AD$400=""
then by default its false when it does not =""
so the 2nd IF is not necessary

=IF($AD$400="",
COUNTIFS($D$15:$D$300, AG13, $H$15:$H$300, "Scheduled"),
COUNTIFS($AG$15:$AG$300, $BC$3, $D$15:$D$300, AG13, $H$15:$H$300, "Scheduled", $D$15:$D$300, $AD$400) )

this is the same as the rule for IF($AD$400=""
COUNTIFS($D$15:$D$300, AG13, $H$15:$H$300, "Scheduled")))
so will be met when the sell is blank -

BUT is it blank - you say - SELECTION
display the total if there is no selection in AD400.
just put in a cell
=$AD$400=""
see if you get a TRUE


otherwise as said
A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.
 
Upvote 0
IF($AD$400=""
then by default its false when it does not =""
so the 2nd IF is not necessary

=IF($AD$400="",
COUNTIFS($D$15:$D$300, AG13, $H$15:$H$300, "Scheduled"),
COUNTIFS($AG$15:$AG$300, $BC$3, $D$15:$D$300, AG13, $H$15:$H$300, "Scheduled", $D$15:$D$300, $AD$400) )

this is the same as the rule for IF($AD$400=""
COUNTIFS($D$15:$D$300, AG13, $H$15:$H$300, "Scheduled")))
so will be met when the sell is blank -

BUT is it blank - you say - SELECTION

just put in a cell
=$AD$400=""
see if you get a TRUE


otherwise as said
A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.
Thanks for your reply etaf,

I have mocked up a minisheet below,

The expected result in E17 is 2 if there is no selection in E16.
The expected result in E17 is Bunbury is in the selection box E16 is 1.
The expected result in E17 is Metro is in the selection E16 is 1.

On my spreadsheet E16 (the selection box) is controlled from a slicer.

The cell containing a 1 or 2 (on this spreadsheet is F2 containing a 1) is vital for the correct operation of the gantt chart that is in the workbook, 1 refers to completed and 2 refers to Failed.

Hope this helps !!

Thank you again for taking time to look at this.

Stefan

Book2
ABCDEF
2ResourceRegionTypeStatus1/01/20231
3BunburyRegionalUnscheduledNot Completed2
4MetroMetroUnscheduledCompleted1
5MetroMetroUnscheduledNot Completed2
6BroomeRegionalUnscheduledCompleted1
7MetroMetroUnscheduledCompleted1
8MetroMetroScheduledNot Completed2
9MetroMetroScheduledNot Completed2
10MetroMetroScheduledNot Completed2
11MetroMetroScheduledNot Completed2
12MetroMetroScheduledNot Completed2
13MetroMetroScheduledCompleted1
14BunburyRegionalScheduledCompleted1
15West KimberleyRegionalUnscheduledNot Completed2
16MetroMetroUnscheduledNot Completed2
170
18Selection aboveResult above
Sheet1
Cell Formulas
RangeFormula
E3:E16E3=IF(AND(E$13>=$Q3,E$13<=$S3),1,IF(AND(E$13>=$O3,OR(E$13<=$Q3,E$13<=$U3),ISNUMBER($O3)),2,""))
E17E17=IF($D$17="", COUNTIFS($E$3:$E$16, $F$2, $C$3:$C$16, "Scheduled"), COUNTIFS($E$3:$E$16, $F$2, $A$3:$A$16, E2, $C$3:$C$16, "Scheduled", $D$3:$D$16, $D$17))
 
Upvote 0
no not really
E3 to E16 formula
=IF(AND(E$13>=$Q3,E$13<=$S3),1,IF(AND(E$13>=$O3,OR(E$13<=$Q3,E$13<=$U3),ISNUMBER($O3)),2,""))

referes to column S, Q, U < O ????

so i just get all zeros in column E

The expected result in E17 is 2 if there is no selection in E16.
No selection means blank ?

The expected result in E17 is Bunbury is in the selection box E16 is 1.

The expected result in E17 is Metro is in the selection E16 is 1.

=IF( E16="", 2, If( E16=1, "Bunbury", If( E16=2,"Metro","")))

i suspect i'm missing something here

EXCEL FORUM.xlsx
ABCDEFGH
16MetroMetroUnscheduledNot Completed012
172 BunburyMetro
Sheet1
Cell Formulas
RangeFormula
E17:H17E17=IF( E16="", 2, IF( E16=1, "Bunbury", IF( E16=2,"Metro","")))
 
Upvote 0
no not really
E3 to E16 formula
=IF(AND(E$13>=$Q3,E$13<=$S3),1,IF(AND(E$13>=$O3,OR(E$13<=$Q3,E$13<=$U3),ISNUMBER($O3)),2,""))

referes to column S, Q, U < O ????

so i just get all zeros in column E

The expected result in E17 is 2 if there is no selection in E16.
No selection means blank ?

The expected result in E17 is Bunbury is in the selection box E16 is 1.

The expected result in E17 is Metro is in the selection E16 is 1.

=IF( E16="", 2, If( E16=1, "Bunbury", If( E16=2,"Metro","")))

i suspect i'm missing something here

EXCEL FORUM.xlsx
ABCDEFGH
16MetroMetroUnscheduledNot Completed012
172 BunburyMetro
Sheet1
Cell Formulas
RangeFormula
E17:H17E17=IF( E16="", 2, IF( E16=1, "Bunbury", IF( E16=2,"Metro","")))
Hopefully the below is better,

The formula referring to S,Q and so on is for the conditional formatting of the gantt chart.

The selection box, yes you're right Blank.

The Selection box is controlled by a slicer, so depending on what is selected on the slicer is what displays in the selection box.

The expected result in X65 if Bunbury is in the selection box (U62 in this mini sheet) is 1.

The expected result in X65 if Metro is in the selection box (U62 in this mini sheet) is 1.

minisheet 13.6.23 1.xlsx
BCDEFGHIJKLMRSUWX
131
14Region ResourcingRegionTypeStatusReceived dateReceived TimeStart DateStart TimeEnd DateEnd TimeRTP DateRTP TimeDays, Hours, Minutes until StartedTotal SpanWorked on SpanSpan %T
16BunburyRegionalUnscheduledNot Completed22/5/2311:262/6/2312:58 11 Days 1 h 32 m 0%2
17MetroMetroUnscheduledCompleted23/5/236:3025/5/2315:157/6/2314:302 days 8 h 45 m15 Days 8 h 0 m12 Days 23 h 15 m85%1
20MetroMetroUnscheduledNot Completed28/5/238:384/6/2317:50 7 Days 9 h 12 m 0%2
21BroomeRegionalUnscheduledCompleted29/5/2315:0430/5/2314:056/6/235:380 days 23 h 01 m7 Days 14 h 34 m6 Days 15 h 33 m87%1
22MetroMetroUnscheduledCompleted31/5/2318:0231/5/2319:451/6/237:310 days 1 h 43 m0 Days 13 h 29 m0 Days 11 h 46 m87%1
23MetroMetroScheduledNot Completed1/6/231/6/23 0 Days 0 h 0 m 0%2
24MetroMetroScheduledNot Completed1/6/231/6/23 0 Days 0 h 0 m 0%2
25MetroMetroScheduledNot Completed1/6/231/6/23 0 Days 0 h 0 m 0%2
26MetroMetroScheduledNot Completed1/6/231/6/23 0 Days 0 h 0 m 0%2
27MetroMetroScheduledNot Completed1/6/231/6/23 0 Days 0 h 0 m 0%2
28MetroMetroScheduledCompleted1/6/2310:151/6/2317:22  0 Days 7 h 7 m100%1
29BunburyRegionalScheduledCompleted1/6/235:451/6/2311:20  0 Days 5 h 35 m100%1
30West KimberleyRegionalUnscheduledNot Completed1/6/2312:214/6/2311:23 2 Days 23 h 2 m 0%2
31MetroMetroUnscheduledNot Completed1/6/2313:432/6/2318:16 1 Days 4 h 33 m 0%2
32MetroMetroScheduledCompleted2/6/238:382/6/2320:15  0 Days 11 h 37 m100% 
33MetroMetroUnscheduledNot Completed3/6/238:103/6/2315:21 0 Days 7 h 11 m 0% 
34MetroMetroScheduledCompleted2/6/2310:162/6/2317:05  0 Days 6 h 49 m100% 
35MetroMetroScheduledCompleted2/6/2310:212/6/2312:47  0 Days 2 h 26 m100% 
36MetroMetroUnscheduledCompleted1/6/2317:231/6/2318:263/6/2319:220 days 1 h 03 m2 Days 1 h 59 m2 Days 0 h 56 m98%1
37MetroMetroUnscheduledNot Completed2/6/230:254/6/2313:26 2 Days 13 h 1 m 0% 
38MetroMetroUnscheduledNot Completed3/6/237:034/6/2323:00 1 Days 15 h 57 m 0% 
39MetroMetroUnscheduledCompleted3/6/2319:153/6/2321:106/6/2319:190 days 1 h 55 m3 Days 0 h 4 m2 Days 22 h 9 m97% 
40MetroMetroUnscheduledNot Completed3/6/237:034/6/2318:13 1 Days 11 h 10 m 0% 
41West KimberleyRegionalUnscheduledCompleted30/5/2314:164/6/235:304/6/2310:304 days 15 h 14 m4 Days 20 h 14 m0 Days 5 h 0 m4%2
44MetroMetroScheduledCompleted7/6/2310:297/6/2319:15  0 Days 8 h 46 m100% 
45MetroMetroScheduledCompleted7/6/2311:007/6/2317:04  0 Days 6 h 4 m100% 
47MetroMetroScheduledNot Completed7/6/237:308/6/23 0 Days 16 h 30 m 0% 
48MetroMetroScheduledNot Completed8/6/238/6/23 0 Days 0 h 0 m 0% 
50MetroMetroScheduledNot Completed8/6/238/6/23 0 Days 0 h 0 m 0% 
51MetroMetroScheduledCompleted8/6/237:049/6/238:24  1 Days 1 h 20 m100% 
53MetroMetroScheduledNot Completed9/6/239/6/23 0 Days 0 h 0 m 0% 
54MetroMetroScheduledNot Completed9/6/239/6/23 0 Days 0 h 0 m 0% 
57MetroMetroUnscheduledNot Completed7/6/2310:487/6/2321:43 0 Days 10 h 55 m 0% 
59EGRPRegionalUnscheduledNot Completed7/6/2315:388/6/2316:36 1 Days 0 h 58 m 0% 
60MetroMetroUnscheduledNot Completed7/6/2319:158/6/2315:18 0 Days 20 h 3 m 0% 
62Broome Completed6
63BunburyFailed10
64EGRP
65MetroScheduled0
66West KimberleyUnscheduled
67(blank)
Worked on Gantt Chart
Cell Formulas
RangeFormula
R16:R17,R20:R41,R44:R45,R47:R48,R50:R51,R53:R54,R57,R59:R60R16=IFERROR(IF(O16-N16=DATE(1900,1,0),"",O16-N16),"")
S16:S17,S20:S41,S44:S45,S47:S48,S50:S51,S53:S54,S57,S59:S60S16=IFERROR(IF(N16="", "", INT(IF(P16="", Q16, P16)-N16) & " Days " & HOUR(IF(P16="", Q16, P16)-N16) & " h " & MINUTE(IF(P16="", Q16, P16)-N16) & " m"), "")
W16:W17,W20:W41,W44:W45,W47:W48,W50:W51,W53:W54,W57,W59:W60W16=IF(AND(T16="", V16=""), 0, IF(T16="", 1, IFERROR(V16/T16, 0)))
U16:U17,U20:U41,U44:U45,U47:U48,U50:U51,U53:U54,U57,U59:U60U16=IF(OR(P16="", O16=""), "", INT(P16-O16) & " Days " & HOUR(P16-O16) & " h " & MINUTE(P16-O16) & " m")
U62U62=IF(COUNTA(S62:S79)>1,"",IF(S62<>"",S62,""))
X13X13=W11
X14X14=LEFT(TEXT(X13,"ddd"),1)
X16:X17,X20:X41,X44:X45,X47:X48,X50:X51,X53:X54,X57,X59:X60X16=IF(AND(X$13>=$H16,X$13<=$J16),1,IF(AND(X$13>=$F16,OR(X$13<=$H16,X$13<=$L16),ISNUMBER($F16)),2,""))
X62X62=IF($U$62<>"", COUNTIFS(X15:X61, $AT$3, $B$15:$B$61, $U62), COUNTIF(X15:X61, 1))
X63X63=IF($U$62<>"", COUNTIFS(X15:X61, $AT$5, $B$15:$B$61, $U62), COUNTIF(X15:X61, 2))
X65X65=IF($U$62="", COUNTIFS($X$15:$X$61, $AT$3, $B$15:$B$61, X13, $D$15:$D$61, "Scheduled"), COUNTIFS($X$15:$X$61, $AT$3, $B$15:$B$61, $U$62, $D$15:$D$61, "Scheduled"))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
X15:BB61Expression=AND(X$13>=$H15,X$13<=$J15)textNO
X15:BB61Expression=AND(X$13>=$F15,OR(X$13<=$H15,X$13<=$L15),ISNUMBER($F15))textNO
W15:W61Other TypeDataBarNO
Cells with Data Validation
CellAllowCriteria
B15:B61List=$ES$35:$ES$46
C15:C61List=$ES$15:$ES$17
D15:D61List=$ET$15:$ET$17
E15:E61List=$EW$15:$EW$21
 
Upvote 0
i'm really sorry, been through a few times again, I'm just not understanding what you want , as it seems to be changing each time

The original post - talked about totals
If anyone is able to see where or what i need to change in the above formula to make the total display when there is no selection in AD400, that would be amazing.
And i correct the formula and suggested a mini sheet - BUT that seems to have changed the question

you said in post #4 -
The expected result in E17 is 2 if there is no selection in E16.
The expected result in E17 is Bunbury is in the selection box E16 is 1.
The expected result in E17 is Metro is in the selection E16 is 1.
I gave you a formula
=IF( E16="", 2, If( E16=1, "Bunbury", If( E16=2,"Metro","")))

So that was for a cell E17

Which you have NOT commented - on and in your reply
post #6
The expected result in X65 if Bunbury is in the selection box (U62 in this mini sheet) is 1.

The expected result in X65 if Metro is in the selection box (U62 in this mini sheet) is 1.
Now we are talking about a different cell X65 and a different set of results

before it was to return a word based on a value

Now its a value based on a word

so here goes
which is the same result of 1
=IF( OR( U62="Banbury", U62="Metro") , 1 , "")

as i say , i'm just not following now at all what you need
 
Upvote 0
i'm really sorry, been through a few times again, I'm just not understanding what you want , as it seems to be changing each time

The original post - talked about totals

And i correct the formula and suggested a mini sheet - BUT that seems to have changed the question

you said in post #4 -

I gave you a formula
=IF( E16="", 2, If( E16=1, "Bunbury", If( E16=2,"Metro","")))

So that was for a cell E17

Which you have NOT commented - on and in your reply
post #6

Now we are talking about a different cell X65 and a different set of results

before it was to return a word based on a value

Now its a value based on a word

so here goes
which is the same result of 1
=IF( OR( U62="Banbury", U62="Metro") , 1 , "")

as i say , i'm just not following now at all what you need
Hi etaf,

Really sorry for being inconsistent, the last minisheet i posted was from my actual spreadsheet with all sensitive data hidden as suggested by awoohaw, thank you awoohaw,

By providing the actual sheet, i thought it would make things clearer, sorry it has not.

Your formula, =IF( E16="", 2, If( E16=1, "Bunbury", If( E16=2,"Metro",""))) is great if the only two selections were Bunbury and Metro, there is more than two and as i said the selection is controlled by a slicer.

From the last minisheet posted, I would like X65 to display the total for scheduled from the 01/06 in cell X13 if there is no selection in U62 (U62 is controlled from a slicer for the pivot table S62 to S67).

So the expected result if no selection is U62 would be 2.
If Bunbury was selected the expected result would be 1.
If Metro was selected the expected result would be 1.

If this does not make sense, thats ok, I confuse myself!!

I am thinking about ditching the idea as it is becoming a headache, but i would like it to work.

I really appreciate your time etaf and I am sorry for the confusion.
 
Upvote 0
Your formula, =IF( E16="", 2, If( E16=1, "Bunbury", If( E16=2,"Metro",""))) is great if the only two selections were Bunbury and Metro, there is more than two and as i said the selection is controlled by a slicer.
so what are all the possible selections and result required - a simple lookup on a reference table would solve that quite easily

Broome
Bunbury
EGRP
Metro
West Kimberley
(blank)

So the expected result if no selection is U62 would be 2.
If Bunbury was selected the expected result would be 1.
If Metro was selected the expected result would be 1.

again you have only shown 3 conditions
No Selection , Bunbury & Metro
But said
is great if the only two selections were Bunbury and Metro, there is more than two and as i said the selection is controlled by a slicer.

I am thinking about ditching the idea as it is becoming a headache, but i would like it to work.

sorry its a headache for you and I'm sure an easy solution is available

perhaps a share version of the spreadsheet - with expected results shown ..........

Hopefully another member will pick up the thread and understand what you are after and help further
 
Upvote 0
so what are all the possible selections and result required - a simple lookup on a reference table would solve that quite easily

Broome
Bunbury
EGRP
Metro
West Kimberley
(blank)



again you have only shown 3 conditions
No Selection , Bunbury & Metro
But said




sorry its a headache for you and I'm sure an easy solution is available

perhaps a share version of the spreadsheet - with expected results shown ..........

Hopefully another member will pick up the thread and understand what you are after and help further
I have taken a different approach to my problem and using a pivot chart in a tabular format using a different criteria from the spreadsheet has solved my problem, it's not exactly as i would have liked it but it works well and displays all the information i need to be displayed.

My brain turned to mush trying to work out the formula.

I thank you so much for your time etaf.
 
Upvote 0

Forum statistics

Threads
1,215,079
Messages
6,122,998
Members
449,092
Latest member
masterms

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