# Set-OfficeExcelChartTrendline

Adds or replaces a series trendline. Review available syntax, parameters, pipeline guidance, and reference details in PSWriteOffice Cmdlet Reference.

Cmdlet 

Aliases: ExcelChartTrendline

**Module**

`PSWriteOffice`

**Aliases**

`ExcelChartTrendline`

**Inputs**

`OfficeIMO.Excel.ExcelChart`

**Source**

[SetOfficeExcelChartTrendlineCommand.cs:36](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Excel/SetOfficeExcelChartTrendlineCommand.cs#L36) 

Adds or replaces a series trendline.

## Syntax

```
Set-OfficeExcelChartTrendline
[-Backward <Double>]
[-Chart] <ExcelChart>
[-DisplayEquation]
[-DisplayRSquared]
[-Forward <Double>]
-Index <Int32>
[-Intercept <Double>]
[-LineColor <OfficeColor>]
[-LineWidth <OfficeLength>]
[-Order <Int32>]
[-PassThru]
[-Period <Int32>]
[-Type <OfficeChartTrendlineType>]
[<CommonParameters>]
```

[#](#method-set-officeexcelcharttrendline-double-excelchart-switchparameter-switchparameter-double-int32-double-officecolor-officelength-int32-switchparameter-int32-officecharttrendlinetype)

Parameter set: `Index`

```
Set-OfficeExcelChartTrendline
[-Backward <Double>]
[-CaseSensitive]
[-Chart] <ExcelChart>
[-DisplayEquation]
[-DisplayRSquared]
[-Forward <Double>]
[-Intercept <Double>]
[-LineColor <OfficeColor>]
[-LineWidth <OfficeLength>]
-Name <String>
[-Order <Int32>]
[-PassThru]
[-Period <Int32>]
[-Type <OfficeChartTrendlineType>]
[<CommonParameters>]
```

[#](#member-d1451ba3fccd408b01c0ad50)

Parameter set: `Name`

## Examples

### Add a linear trendline

```powershell
New-OfficeExcel -Path .\Reports\Growth.xlsx {
    ExcelSheet 'Users' {
        ExcelChart -InputObject (Import-OfficeCsv -Path .\Data\Monthly-Users.csv) -Category Month -Value ActiveUsers -Type Line -Address A1 -PassThru | ExcelChartTrendline -Index 1 -Type Linear
    }
}
```

Adds a straight trendline to the first series.

### Project storage growth

```powershell
New-OfficeExcel -Path .\Reports\Storage-Forecast.xlsx {
    ExcelSheet 'Storage' {
        $chart = ExcelChart -InputObject (Import-OfficeCsv -Path .\Data\Storage-Used.csv) -Category Month -Value UsedTB -Type Line -Address A1 -Title 'Storage used (TB)' -PassThru
        ExcelChartTrendline -Chart $chart -Name UsedTB -Type Linear -Forward 3 -DisplayRSquared
    }
}
```

Fits a trendline to monthly storage use, projects it three months forward and shows the R-squared value on the chart.

## Parameters

**-Backward Double optional**

Backward forecast units.

**-Chart ExcelChart requiredposition: 0pipeline: True (ByValue)**

Chart to update.

**-DisplayEquation SwitchParameter optional**

Display the trendline equation.

**-DisplayRSquared SwitchParameter optional**

Display the R-squared value.

**-Forward Double optional**

Forward forecast units.

**-Index Int32 requiredsets: Index**

One-based index identifying the target item.

**-Intercept Double optional**

Trendline intercept.

**-LineColor OfficeColor optional**

Trendline line color. Named colors and hexadecimal values are accepted.

**-LineWidth OfficeLength optional**

Physical line width; numbers are interpreted as points.

**-Order Int32 optional**

Polynomial order.

**-PassThru SwitchParameter optional**

Emits the native result after the operation.

**-Period Int32 optional**

Moving-average period.

**-Type OfficeChartTrendlineType optional**

Trendline type.

Possible values: `Exponential`, `Linear`, `Logarithmic`, `MovingAverage`, `Polynomial`, `Power`

**-CaseSensitive SwitchParameter optionalsets: Name**

Matches names and text using ordinal case sensitivity. Omission ignores case.

**-Name String requiredsets: Name**

Named range name.

## Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see [about_CommonParameters](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

<!-- PowerForge markdown artifact sha256:B360D593F89E5EF677AAB534E439D9303AB5F1092E473018F08C34F1F116C6BF -->
