I have two objects A and B related through lookup. Object A has a lookup relationship field to object B. I need to display a custom field from object B in a report which is based on object A. Is it a good idea to create a formula field in object A and use that field in report. Is there any better alternative available ? Will it be slower (or not a good practice) to do it using a formula field and not creating a custom report type ? Is there a way to find out if a report is build using default / standard report type ?
Salesforce provides relationship fields (like lookup or master detail) based on which we can setup relationship among objects.
We can easily filter set of records based on query or filter condition.
Is it a good idea to create a formula field in object A and use that field in report. Is there any better alternative available ? Will it be slower (or not a good practice) to do it using a formula field and not creating a custom report type ?
It depends on the purpose of your requirement. More over, using formula field in query condition slower the retrieval process because formula field is not indexed.
We can traverse up to 5 related objects based on the relationship.
Formula field is good if you try to display parent's information on the child object or try to achieve some calculation or you want put information combining different field values.
Now, if you try to display child's information at Parent then formula field will not work.
So, if we achieve results from our relationship fields then it is not advisable to create duplicate formula fields just to show the related record information.
Is there a way to find out if a report is build using default / standard report type ?
Now, according to your requirement, if you have custom objects, then Salesforce cannot provide standard report type for your relationship. That's why you need to create custom report type and define how you could create reports based on that.
For more information, refer Set Up a Custom Report Type
Just adding this here for others. I found another (and maybe more suiting) answer here: https://success.salesforce.com/answers?id=90630000000ZjPZAA0
If it's a lookup field to relate just a single object, there's no need to create a bloated relationship, or formula fields. (You still need to create a custom report for object A though.)
You can add fields from object B to your object A report type by editing the report type's layout. On the right hand side you will find a box that says "Add fields related via lookup". There, you can browse every lookup field for every object that is involved in that report type and add the relation's fields.