Forum Discussion

Swetha_24's avatar
Swetha_24
Frequent Visitor
2 years ago

How to Create a Line Chart with Multiple Material Codes and Total Quantity in Power BI

Hello,
i need assistance with creating a dynmic line chart in power bi. I have a dataset with the following columns: date, material code and quantity. My goal is to create a line chart that updated based on the selected material code using a slicer.
here are the specific requirements:
- i want to create a slicer for the material code column
- when i select a single material code form the slicer, the line chart should displaythe total quantity for the material code over time
- when i select multiple material codes from the slicer, the line chart should show multiple lines, each representing the total quantity for each selected material code over time
Additionally, the line chart should display a line that represents the total quantity of all selected material codes combined over time

Example:
- If I select Material Code "A" and "B" from the slicer, the line chart should display:
- A line showing the total quantity for Material Code "A" over time.
- A line showing the total quantity for Material Code "B" over time.
- An additional line showing the combined total quantity for both Material Code "A" and "B" over time.
->Dataset Information:
The dataset contains more than 100 material codes.
What I have tried:
I have created the following DAX measures:
-DAX
Total_quantity_dynamic =
SUM('Sheet'[accept_quantity])

Combined_total_quantity_selected =
CALCULATE(
SUM('Sheet'[accept_quantity]),
ALLSELECTED('Sheet')
)
Using these measures, I can create a slicer for Material Code and a line chart. However, I am having trouble achieving the desired behavior where the line chart shows separate lines for each selected material code along with an additional combined total line.

What I Need Help With:
-How can I dynamically display separate lines for each selected material code using DAX or any other method in Power BI?
-How can I add a line that represents the combined total quantity of the selected material codes over time?
Any assistance or guidance on how to achieve this in Power BI would be greatly appreciated.

Thank you!

2 Replies

    • Swetha_24's avatar
      Swetha_24
      Frequent Visitor

       

      Hi @Yulia Xu

      Here is the sample data for reference

       

       

      Currently, my line chart only shows the total quantity line, but I want to display separate lines for each selected material code along with the total quantity line for the selected material codes.

      Best Regards,

      Swetha