I have created the formula that I want using the following:
=CONCATENATE("=LET(a,UNIQUE('Maintenance Data'!$A$2:$A$",'Defined Information'!C17,"),b,MAXIFS('Maintenance Data'!$Y$2:$Y$",'Defined Information'!C17,",'Maintenance Data'!$A$2:$A$",'Defined Information'!C17,",a),c,SORTBY(a,b,-1),d,SEQUENCE(ROWS(c)),e,XLOOKUP('Maintenance Data'!$A$2:$A$",'Defined Information'!C17,",c,d),SORTBY('Maintenance Data'!$A$2:$Y$",'Defined Information'!C17,",e,,'Maintenance Data'!$Y$2:$Y$",'Defined Information'!C17,",-1))")
where Defined Information C17 has a row count in it but this obviously only returns a text string, is there a way to use the INDIRECT function to create a formula from this?