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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Balta-expertise
Regular Visitor

Line Chart - 2 color in the same line

Hi Everyone,

 

I've an issue and I'm out of the solution

 

I've two data base :

- The first is for the real financial data ;

- The second is for the forecasted financial data ;

=> both base are identical (same column, same format of data item....)

=> There is always 12 months, no partial analyze

 

I want to create a line chart represent the the cumulative amount per month where :

- The real data is on line ;

- The reforcast is on dashed line ;

 

Baltaexpertise_0-1627542645977.png

 

For that, I've a cumulative measure :

- Cumulative amount : =CALCULATE(SUM('PL_cumulé'[Solde]),FILTER(ALLSELECTED('PL_cumulé'),'PL_cumulé'[Date] <=MAX('PL_cumulé'[Date]))

 

When I create a line chart, there is always a blank for the period beetwen real/reforecast. Does anyone know how to fill the blank to have one complete line. The first part is fill and the second on is dashed 

Baltaexpertise_1-1627543153794.png

 

Baltaexpertise_2-1627543307418.png

 

Thank you for your help guys !

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Balta-expertise,

You can use measure expression to replace raw value fields and add if statement on these values to skip calculation on speed ranges After these steps, power bi will auto-hidden these blank parts.

Regards,

Xiaoxin Sheng

View solution in original post

6 REPLIES 6
telesforo1969
Helper V
Helper V

real vs pronostico.JPG

 

1.- crea una columna con la fecha (Eje X)

2.- columna con los valores (Eje Y)

3.- columna con etiquetas Real y Pronóstico, (según corresponda a los valores)

4.- columna Categoría (leyenda), en mi ejemplo tengo dos tipos de combustibles, este es mi caso
5.- En tu tabla agrega una columna concatenando la columna 3 y 4 
 6.- la columna creada en el paso 5 la colocas en Leyenda.
7.- cambia los estilos de líneas

This helped a lot, though an adjustment. Thank you!

amitchandak
Super User
Super User

@Balta-expertise , I a single line you can not get dashed and normal line. So you need to two measure. In two measures you will not have a connection

 

You can have a single measure but the line color will not be different.

 

example: assuming you have given actual, using a common date table

- Cumulative amount : =CALCULATE(SUM('PL_cumulé'[Solde]) + Sum(Target[Target]) ,FILTER(ALLSELECTED('Date'),'Date'[Date] <=MAX('Date'[Date]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Got it !

 

First, I calculate the cumulative amount

Second, I created 2 measures (as you sugget) with the filter on the data source base on the first calculate :

 

First :

CA_progressif =
CALCULATE(
SUM('CA_N_N-1_N-2'[Solde_économique]),
FILTER(
ALLSELECTED('CA_N_N-1_N-2'),
'CA_N_N-1_N-2'[Date] <=MAX('CA_N_N-1_N-2'[Date])))
 
Second : 
CA_progressif_n =
CALCULATE('CA_N_N-1_N-2'[CA_progressif],
'CA_N_N-1_N-2'[Année]="n")
 
and
 
CA_progressif_n-1 =
CALCULATE('CA_N_N-1_N-2'[CA_progressif],
'CA_N_N-1_N-2'[Année]="n-1")

hi @amitchandak ,

Thank you for your answer. What represent the "Target" on your SUM function ? When I try with 2 measures, they are superimposed. I try to add a filter on the calculate function but the lines doesn't stop and continued until the end of the year:

2021-07-29_15-45-28.jpg

 

Thank you very much fr your help. It's is more easy, I can share the PBIX File via dropbox ?

Jules

Anonymous
Not applicable

Hi @Balta-expertise,

You can use measure expression to replace raw value fields and add if statement on these values to skip calculation on speed ranges After these steps, power bi will auto-hidden these blank parts.

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.