Forum Discussion

Fali324's avatar
Fali324
Helper II
1 year ago
Solved

Line chart customisation

Hi,

I have this line chart which is set up in the following way:
X axis - Stage
Y Axis - Duration
Legend - Project


I have a slicer with the columns Project & Active which is yes/no for each project. For all the projects I select yes I want the line to appear but leave the rest as dots. How can I make this possible?

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Fali324 

     

    Certainly, please check the following changes:

    Change the x-asix Table:

     

     

    X-axis =
    UNION (
        VALUES ( 'Table'[Project] ),
        SELECTCOLUMNS (
            VALUES ( 'Table'[Project] ),
            "Project", "Select-" & 'Table'[Project]
        )
    )
    

     

     

    And so do the Measure:

     

     

    MEASURE =
    VAR _Slicer =
        VALUES ( Slicer[Project] )
    VAR _length =
        MAXX ( ADDCOLUMNS ( 'X-axis', "Length", LEN ( 'X-axis'[Project] ) ), [Length] ) - 7
    VAR _CurrentPro =
        SELECTEDVALUE ( 'X-axis'[Project] )
    RETURN
        IF (
            _CurrentPro IN VALUES ( 'Table'[Project] ),
            CALCULATE ( SUM ( 'Table'[Duraction] ), 'Table'[Project] = _CurrentPro ),
            IF (
                ISFILTERED ( Slicer[Project] ),
                CALCULATE (
                    SUM ( 'Table'[Duraction] ),
                    'Table'[Project]
                        IN _Slicer
                            && 'Table'[Project] = MID ( SELECTEDVALUE ( 'X-axis'[Project] ), 8, _length )
                )
            )
        )
    

     

     

    Then select all the selections of the Slicer and Open all the lines of the selections with "Select-":

    You can alse change the Color:

     

    The result is as follow:

    Best Regards

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

     

5 Replies

  • freginier's avatar
    freginier
    Solution Sage

    Hello there!

    If I understood correctly, 

    you're trying to modify a line chart in Power BI so that when you filter by Active projects (Yes/No), the selected projects (Yes) appear as lines and the remaining projects (No) remain as dots.

    This is what I think you should try: 

    Create Two Measures: 
    - One for Active Projects (to display as a line).
    - One for Inactive Projects (to display as dots).
    DAX MeasuresMeasure for Active Projects (Yes - Line): ActiveProjectDuration =
    IF(
    SELECTEDVALUE(Projects[Active]) = "Yes",
    SUM(Projects[Duration]),
    BLANK()
    )

    Measure for Inactive Projects (No - Dots): InactiveProjectDuration =
    IF(
    SELECTEDVALUE(Projects[Active]) = "No",
    SUM(Projects[Duration]),
    BLANK()
    )

    Then layer the two charts together!

    Hope this helps 🙂

     

     

  • that doesn't quite work becuase the legend colours will be different becuase each graph has a different selection of graphs due to the mesure.
    I can modify the graph manuals by switching the lines on  by selecting the series but I just wanted this to be done via a slicer rather than manual 

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi   Fali324 

      Unfortunately that power bi doesn't support this feature currently.

      Please try this alternative workaround:

      Here I create a set of sample:

      Then add 2 calculated tables:

       

      Slicer =
      VALUES ( 'Table'[Project] )
      
      X-axis = UNION(VALUES('Table'[Project]),{"Selectedvalue"})
      

       


      Create a measure:

       

      MEASURE =
      VAR _Slicer =
          SELECTEDVALUE ( Slicer[Project] )
      VAR _CurrentPro =
          SELECTEDVALUE ( 'X-axis'[Project] )
      RETURN
          IF (
              _CurrentPro IN VALUES ( 'Table'[Project] ),
              CALCULATE ( SUM ( 'Table'[Duraction] ), 'Table'[Project] = _CurrentPro ),
              CALCULATE ( SUM ( 'Table'[Duraction] ), 'Table'[Project] = _Slicer )
          )
      

       


      Finally add a line chart with the following fields:

      Close all the lines but Selectedvalue and open all the points except Selectedvalue:

       

      The result is as follow:

       

       

      Best Regards

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

      • Fali324's avatar
        Fali324
        Helper II

        Can this be altered if multiple projects are selected?