I have formula field class name which fetch the mentor first name and last name+ student first name, last name which have lookup related to contact. Now, if student firstname and last name is null then it will fetch lead firstname and lastname which is lookup field related to lead. Here's what I tried so far:
IF( AND ( ISBLANK(Student__r.FirstName),ISBLANK(Student__r.LastName) ), 'Mentor' + " " +Mentor__r.FirstName + " " +Mentor__r.LastName+" "+ 'and'+" " +'Student'+ " " + Lead__r.FirstName + " " + Lead__r.LastName + " "+ "-" +" "+ 'class start time:' +" "+Text(CreatedDate), 'Mentor' + " " +Mentor__r.FirstName + " " +Mentor__r.LastName+" "+ 'and'+" " +'Student'+ " " +Student__r.FirstName + " " + Student__r.LastName + " "+ "-" +" "+ 'class start time:' +" "+Text(CreatedDate) )