Forum Discussion
Toggle Trend Line Button
Hello,
In my opinion, you have, at least two ways to achieve it.
1. Create a toggle button On/Off and associate it the bookmars;
2. Create your own DAX code to create a trend line, then use it, for example, with a Fields Parameter.
Here an example of a DAX measure.
Adapt it to your model.
TrendLine =
VAR AvgX = AVERAGE(DS_Tariff_By_Day[Tariff_Day])
VAR AvgY = AVERAGE(DS_Tariff[Value])
VAR MinStartDate = MIN(DS_Tariff[StartValidityDate])
VAR DaysSinceStart = DATEDIFF(MinStartDate, DS_Tariff_By_Day[Tariff_Day], DAY)
VAR Numerator = SUMX(DS_Tariff, ([Value] - AvgY) * (DaysSinceStart - AvgX))
VAR Denominator = SUMX(DS_Tariff, POWER(DaysSinceStart - AvgX, 2))
VAR Slope = Numerator / Denominator
VAR Intercept = AvgY - Slope * AvgX
RETURN Slope * AvgX + Intercept
Let me know if it help you.