Power BI单数据集多折线图绘制求助:基于单列不同筛选条件
Hey there! I’ve run into this exact scenario countless times—wanting multiple lines in one chart that share most filters but differ on a single column. Let me break down the two best ways to solve this, starting with the most straightforward method.
Method 1: Use DAX Measures (Recommended for Flexibility)
This approach keeps your original dataset intact and lets you dynamically apply shared filters without extra data reshaping.
Step 1: Create a Measure for Each Column A Value
For every distinct value in Column A that you want a line for, create a dedicated measure using CALCULATE. This function will respect your shared filters while adding the unique Column A filter for each line.
For example, if your table is named SalesData, your numeric column is Revenue, and Column A has values "1" and "2", your measures would look like:
Revenue for A=1 = CALCULATE(SUM(SalesData[Revenue]), SalesData[Column A] = "1") Revenue for A=2 = CALCULATE(SUM(SalesData[Revenue]), SalesData[Column A] = "2")
The CALCULATE function automatically inherits any existing filters (your 3 shared ones) and adds the specific Column A filter on top.
Step 2: Build Your Line Chart
- Drag your shared axis (e.g.,
Date) to the X-axis of a line chart. - Drag each of your new measures to the Values section of the Y-axis.
- Apply your 3 shared filters (via slicers, page filters, or report filters)—all lines will automatically use these filters while sticking to their unique Column A value.
Method 2: Reshape Your Data (Good for Fixed Column A Values)
If you prefer working with a reshaped dataset instead of measures, you can use Power Query to pivot your data so each Column A value becomes a separate column.
Step 1: Pivot in Power Query
- Load your dataset into Power Query Editor.
- Select Column A and your numeric column (e.g.,
Revenue). - Go to Transform > Pivot Column.
- Choose your numeric column as the "Values Column" and leave "Advanced options" set to "Sum" (or your preferred aggregation).
- This will create a new column for each value in Column A (e.g.,
Revenue_1,Revenue_2).
Step 2: Build the Chart
- Use the pivoted columns as your Y-axis values, add your shared X-axis, and apply your 3 filters—same as the measure method.
Pro Tip for Many Column A Values
If Column A has dozens of distinct values, manually creating measures is tedious. Instead, use Field Parameters:
- Create a field parameter that includes all distinct values from Column A.
- Write a single dynamic measure that uses
SELECTEDVALUEto pick the right Column A value based on the parameter. - Add the parameter to your chart's legend to toggle lines on/off dynamically.
内容的提问来源于stack exchange,提问作者Juan Carlos Joaquin

