Forum Discussion

Balta-expertise's avatar
Balta-expertise
Regular Visitor
5 years ago
Solved

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 ;

 

 

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 

 

 

Thank you for your help guys !

 

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    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

6 Replies

  •  

    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

    • Anonymous's avatar
      Anonymous
      Not applicable

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

  • 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]))

    • Balta-expertise's avatar
      Balta-expertise
      Regular Visitor

      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:

       

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

      Jules

      • Anonymous's avatar
        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

    • Balta-expertise's avatar
      Balta-expertise
      Regular Visitor

      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")