Aug 11 2022 05:29 AM
Hi i have a formula which works fine in google sheets but im wanting to move over to excel but the formula doesn't work. im sure it may need a slight adjustment but i cant figure it out.
this is the formula in google:
=IFERROR(IF(VLOOKUP(B4,FILTER({$B$3:$B3,$I$3:$J3},$B$3:$B3=B4),2,1)>0,ROUNDDOWN((SUM($I$3:$I3))*1%,1),IF(VLOOKUP(B4,FILTER({$B$3:$B3,$I$3:$I3},$B$3:$B3=B4),2,2)<0,VLOOKUP(B4,FILTER($B$3:$I3,$B$3:$B3=B4),8,1)*-2,IF(VLOOKUP(B4,FILTER({$B$3:$B3,$I$3:$I3},$B$3:$B3=B4),2,2)=0,VLOOKUP(B4,FILTER($B$3:$I3,$B$3:$B3=B4),2,1)*1))))
Thanks
Stu
Aug 11 2022 05:46 AM
That's a long formula; it's hard to visualize what it does. Could you attach a sample workbook (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar? Thanks in advance.
Aug 11 2022 05:49 AM
Aug 11 2022 06:13 AM - edited Aug 11 2022 06:16 AM
Solution
I agree with @Hans Vogelaar that a sample sheet would be helpful but I do see a couple things:
=IFERROR(
IF(VLOOKUP(B4,FILTER({$B$3:$B3,$I$3:$J3},$B$3:$B3=B4),2,1)>0,
ROUNDDOWN((SUM($I$3:$I3))*1%,1),
IF(VLOOKUP(B4,FILTER({$B$3:$B3,$I$3:$I3},$B$3:$B3=B4),2,2)<0,
VLOOKUP(B4,FILTER($B$3:$I3,$B$3:$B3=B4),8,1)*-2,
IF(VLOOKUP(B4,FILTER({$B$3:$B3,$I$3:$I3},$B$3:$B3=B4),2,2)=0,
VLOOKUP(B4,FILTER($B$3:$I3,$B$3:$B3=B4),2,1)*1
)
)
)
)
so I think the problem is the FILTER({...} ...
you can't create a set of ranges like that. Just filter the entire range and pick the column accordingly. I also tried to simplify the whole equation by checking the sign of that result instead of <0, =0 and >0:
=IFERROR(
CHOOSE(SIGN(VLOOKUP(B4,FILTER($B$3:$J3,$B$3:$B3=B4),8,1))+2,
VLOOKUP(B4,FILTER($B$3:$I3,$B$3:$B3=B4),8,1)*-2,
VLOOKUP(B4,FILTER($B$3:$I3,$B$3:$B3=B4),2,1)*1,
ROUNDDOWN((SUM($I$3:$I3))*1%,1)
),
"error"
)
that said there are a couple other things I question:
a) in the VLOOKUPs the last parameter was a 2 in a couple cases when that is really a true/false but I assume any value will come back the same as true
b) in the <0 case you are returning a lookup from column I (3rd parameter is
c) you have an IFERROR() but I didn't see it being used so I added a "error" statement because excel doesn't allow nothing (but apparently sheets does)
Aug 11 2022 06:26 AM
Aug 11 2022 06:50 AM
That could be
=IFERROR(
IF( VLOOKUP( B4, FILTER( HSTACK( $B$3:$B3, $I$3:$J3 ), $B$3:$B3=B4 ), 2, 1)>0,
ROUNDDOWN( SUM($I$3:$I3)*1%, 1),
IF( VLOOKUP( B4,FILTER( HSTACK( $B$3:$B3, $I$3:$I3 ),$B$3:$B3=B4 ), 2, 2)<0,
VLOOKUP( B4,FILTER( $B$3:$I3, $B$3:$B3=B4), 8, 1)*-2,
IF( VLOOKUP( B4,FILTER( HSTACK( $B$3:$B3, $I$3:$I3 ), $B$3:$B3=B4 ), 2, 2)=0,
VLOOKUP( B4,FILTER( $B$3:$I3, $B$3:$B3=B4 ), 2, 1)*1))),
0 )