IF x=0, then omit

Fester675

Board Regular
Joined
Sep 16, 2016
Messages
141
29Hrs (M=0 T=7.5 W=7 Th=7.25 F=7.25) 7 days 11/11/2019
0111110
501
25Hrs (M=6.5 T=7 W=6.5 Th=5 F=0) 7 days 11/11/2019
0111110
501

So column A is a shift pattern; column B is a lookup value based on binary; column C is the corresponding code relating to days of the week worked. e.g. M,T,W,Th,F all worked = 501
However, there are instances as above whereby the data in-putter includes a '0' for a particular day - my question is, is it possible to include a formula that detects the (M etc.)=0, doesn't include it in the binary, and brings back the correct schedule code?
Row 1 should therefore read 0011110 and 405. Formula to detect binary - =TEXTJOIN("",,ISNUMBER(SEARCH("(* "&{"Sn","M","T","W","Th","F","S"}&"=* *)",SUBSTITUTE(SUBSTITUTE(F1274,"(","( "),")"," )")))+0)
Formula to detect code - =IF(ISNUMBER(SEARCH("37*",F1274)),$B$42,INDEX($B$2:$B$43,MATCH(G1274,$C$2:$C$43,0)))

Row 2 should read 0111100 and 401. Binary - =TEXTJOIN("",,ISNUMBER(SEARCH("(* "&{"Sn","M","T","W","Th","F","S"}&"=* *)",SUBSTITUTE(SUBSTITUTE(F1281,"(","( "),")"," )")))+0)
Code - =IF(ISNUMBER(SEARCH("37*",F1281)),$B$42,INDEX($B$2:$B$43,MATCH(G1281,$C$2:$C$43,0)))

Thanks in advance for any help!!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Maybe
+Fluff 1.xlsm
AB
1
229Hrs (M=0 T=7.5 W=7 Th=7.25 F=7.25) 7 days 11/11/20190011110
325Hrs (M=6.5 T=7 W=6.5 Th=5 F=0) 7 days 11/11/20190111100
425Hrs (Sn=6.5 T=7 W=6.5 Th=5 F=0 S=0.5) 7 days 11/11/20201011101
Master
Cell Formulas
RangeFormula
B2:B4B2=TEXTJOIN("",,--ISNUMBER(MATCH({"sn","m","t","w","th","f","s"},FILTERXML("<k><m>"&SUBSTITUTE(SUBSTITUTE(REPLACE(LEFT(A2,FIND(")",A2)-1),1,FIND("(",A2),""),"=","</m><m>")," ","</m><m>")&"</m></k>","//m[.>0]/preceding-sibling::m[1]"),0)))
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

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