Forum Discussion

VijayAntonyM's avatar
VijayAntonyM
Helper I
1 year ago
Solved

Line Chart Legend is not working Dynamically

Hi Team,

 

Good day

 

I have created Line Chart for 2 measures which are Committed and Delievered against some Products and Date columns as below,

 

X-Axis- Release Date

Y-Axis- Product and the values are created in following measures Product1_Committed, Product1_Delivered, Product2_Committed, Product2_Delivered, Product3_Committed,Product3_Delievered.

 

We also placed Product column in filters on all pages pane,  When Product1 is selected respective lines are displaying in line chart but the legend is displaying all products by default as below,

 

 

Please advise how can we display the selected Product alone on the Legend?

 

Thanks in advance

 

Regards

M. Vijay Antony

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi VijayAntonyM ,

     

    Have you filtered the products individually in each product measure? For example: Table [Product] = "Product 1". If my assumption is right, then as danextian said, you just need to create two measures and then use the Product column as Legend, the line chart will automatically show Committed and Delivered for each product, and the Product Filter will work as well.

     

    Here is an example for your reference.

     

    My data

    2024/1/1 10 A
    2024/2/1 15 A
    2024/3/1 26 A
    2024/1/1 16 B
    2024/2/1 5 B
    2024/3/1 18 B

     

    The _sum measure.

    sum_ = CALCULATE(SUM('Table (2)'[Sum]),MONTH('Table (2)'[Date])=MONTH(MAX('Table (2)'[Date])))

    When I selected A in Filter, the line chart showed A product.

     

    The premise of this solution is that the Committed and Delivered of each product are calculated in the same way. Why do you think this solution does not work? Could you please provide more details, such as DAX, screenshots or pbix file? That will help us provide solutions.

     

     

     

     

    ——————————————————————————————————————————————————

    If my answer helps you solve the problem, please accept my answer as a solution and let it be seen by more people in need.

     

    Best regards,

    Mengmeng Li

3 Replies

  • Hi VijayAntonyM 

     

    When you add multiple measures to a line chart, those measures become the legends. If you want to use a column, add a single measure and use that column as a legend.

    • VijayAntonyM's avatar
      VijayAntonyM
      Helper I

      Actually we need to have 2 measures (committed and delivered accordingly) against products, you solution is not possible on the line chart, 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi VijayAntonyM ,

     

    Have you filtered the products individually in each product measure? For example: Table [Product] = "Product 1". If my assumption is right, then as danextian said, you just need to create two measures and then use the Product column as Legend, the line chart will automatically show Committed and Delivered for each product, and the Product Filter will work as well.

     

    Here is an example for your reference.

     

    My data

    2024/1/1 10 A
    2024/2/1 15 A
    2024/3/1 26 A
    2024/1/1 16 B
    2024/2/1 5 B
    2024/3/1 18 B

     

    The _sum measure.

    sum_ = CALCULATE(SUM('Table (2)'[Sum]),MONTH('Table (2)'[Date])=MONTH(MAX('Table (2)'[Date])))

    When I selected A in Filter, the line chart showed A product.

     

    The premise of this solution is that the Committed and Delivered of each product are calculated in the same way. Why do you think this solution does not work? Could you please provide more details, such as DAX, screenshots or pbix file? That will help us provide solutions.

     

     

     

     

    ——————————————————————————————————————————————————

    If my answer helps you solve the problem, please accept my answer as a solution and let it be seen by more people in need.

     

    Best regards,

    Mengmeng Li