Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Prediction Line

I need to create a prediction line for how the progress bar should look like.
(I am using a line and stacked column chart)

motyotyotyo_0-1687947331681.png

In my data table I have begin dates and end dates. I need a measure to choose the earliest and latest dates and create a linear line between it.
The yellow line is a new column, but it gives back the correct line in overall view. But as I use slicer or filter it doesn't change (as expected). Here is the code for it:
Regression =
VAR mind = MIN(Data_Table[Begin Date])
VAR maxd = MAX(Data_Table[End Date])
VAR dat = 'Calendar'[Date]
VAR dated = DATEDIFF(mind,maxd,DAY)
VAR todated = DATEDIFF(dat,maxd,DAY)
VAR fromdated = DATEDIFF(mind,dat,DAY)
RETURN IF(AND(fromdated>=0,todated>=0),(DIVIDE(todated,dated)-1)*(-1),IF(fromdated<0,0,1))

After this I tried to create the measure for it, but it doesn't work like it.
Here is the code:
Regression 2 =
VAR mind = MIN(Data_Table[Begin Date])
VAR maxd = MAX(Data_Table[End Date])
VAR dat = SELECTEDVALUE('Calendar'[Date])
VAR dated = DATEDIFF(mind,maxd,DAY)
VAR todated = DATEDIFF(dat,maxd,DAY)
VAR fromdated = DATEDIFF(mind,dat,DAY)
RETURN IF(AND(fromdated>=0,todated>=0),(DIVIDE(todated,dated)-1)*(-1),IF(fromdated<0,0,IF(todated<0,1,0)))

I don't mind the spikes on the dates where there is no date (missing column), but the slope start later and before that the value is 1 rather 0.

Any help with other approaches as well is much appricated it and have a lovely day.

3 REPLIES 3
some_bih
Super User
Super User

Hi @Anonymous please check that you have the latest version of Power BI. For forecast feature please note

The forecasting feature is only available for line chart visuals.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






some_bih
Super User
Super User

Hi @Anonymous did you try forecasting feature in Power BI

Check link https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-analytics-pane 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Anonymous
Not applicable

Hey
Unfortunately this is not an option as I don't see it.

motyotyotyo_0-1688458420116.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.