Your expression will not work because you are using a attribute which is not applicable to the element being evaluated.
That is you are using in the same expression, both length and width . Width can only be used for windows, etc. and length for curtain walls. -- As you have said. So, any window or curtain wall which sees both attributes will mark one or the other as not applicable and fail.
The solution is to make two separate sequences (expressions) in the same expression using the ADD button,
One which will apply only to windows and one which will apply only to curtain walls. In evaluating the expression, the program will only use the applicable sequence for the correct element.
FYI: make sure you have correctly set the classifications for both elements.
Windows 10 - Visual Studio 2019; ArchiCAD 26