Here is how to create a Power BI line chart that at some point continues in a different design, formatting. For example, it is useful to continue actual data with the forecast but in a different style. In a way, it is conditional formatting for the line chart series in a Power BI.
Here is my table “fact_forecast” and the M code is below this post.
First of all, you should know a condition that determines that the data series will appear in a different look. In my case, if there is no actual data, the line chart series will continue as a dotted line that represents the forecast.
You have to figure out how to get a date that represents the last available fact. Check out this post that explains how to calculate that.
Add a new column to the table called “future_forecast”, where the date for the last fact is in a variable. That will help to return the last actual value, and that will make two different-looking lines connected.
After that, calculate necessary values where the last fact is combined with a forecast for the next available dates.
future_forecast = VAR date_for_the_last_fact = MAXX ( fact_forecast, INT ( NOT ISBLANK ( fact_forecast[fact] ) ) * fact_forecast[date] ) RETURN IF ( date_for_the_last_fact = fact_forecast[date], fact_forecast[fact], IF ( date_for_the_last_fact < fact_forecast[date], fact_forecast[forecast] ) )
As the result, there is a series that continues when the fact series ends.
If you combine date, fact and future_forecast in one Power BI line chart and spend some time format settings, you will get the result that looks like this.
Additional Power BI data visualization tips
By knowing how to choose Power BI measures with the slicer, you can provide a solution that users can choose if it is necessary or not.
Here is the M code for the table that you can use in a blank query.