Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have two reports of data but I want to generate a statement that will only show data from a field if it is populated, and if it isn't populated show the other field.
I know this is a generic IF statement but can't figure out how to word the IF statement for a populated field rather than a specific selection.
Something like:
IF([Mike Risk Factor]=(no idea what to put here), [Mike Risk Factor], [Risk Factor])
Try this,
IF(LEN(TRIM([Mike Risk Factor]))>0, [Mike Risk Factor], [Risk Factor])
Try this,
IF(LEN(TRIM([Mike Risk Factor]))>0, [Mike Risk Factor], [Risk Factor])
You may also want to cater for the case of the field being NULL by using
isnull([Mike Risk Factor])
Try this:
IF([Mike Risk Factor]=' ', [Mike Risk Factor], [Risk Factor]) as Factor
Try this covering both an empty field and a null field
IF(TRIM([Mike Risk Factor])='' OR ISNULL([Mike Risk Factor]), [Risk Factor], [Mike Risk Factor])
My recommendation would already treat the field by removing the nulls with TRIM and it would check if the field size is greater than 0 with LEN thus perfectly servicing the request.
Reguards