1. Drag Sales to Columns and choose the aggregation as Sum.
2. Drag Profit to Rows and choose the aggregation as Sum.
3. Drag Product name to Detail.
4. Select the Analytics Pane > drag trend line and choose Linear.
5. Select Analysis > Create Calculated Field to create a calculated field.
6. In the Calculated Field dialog box that opens, enter a name for the field. In the example workbook, this field is named slope.
7. In the formula field, create a calculated field similar to the following, and then click OK:
8. Create another calculated field intercept with the following formula:
9. Create another calculated field Trend Line Color with the following formula:
SUM([Profit])- [slope]*SUM([Sales])+ [intercept] < 0
10. Drag Trend Line Color calculation to Color on Marks card.
11. Right-click the Trend Line Color on Marks card, select Compute using and Choose Product Name.
12. Select Analysis > Trend Lines > Edit Trend Lines.
13. Under Options Include the following fields as factors: deselect the Trend Line Color check box. Click OK.