Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeExcelChartTrendline

Aliases: ExcelChartTrendline
Module
PSWriteOffice
Aliases
ExcelChartTrendline
Inputs
OfficeIMO.Excel.ExcelChart

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>]
#
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>]
#
Parameter set: Name

Examples

Add a linear trendline

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

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.