Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi all!
I've this Power BI Deneb code to create a scatter chart. It shows open projects (red) and closed projects (blue), plus two trend lines: a black one for all closed projects, and a blue one for the filtered closed projects. The filter distinguishing open and closed uses this column:
ProjectType =
SWITCH(
TRUE(),
facilities[project_phase] = "DETAIL", "Opened",
facilities[project_phase] = "FEED", "Closed",
BLANK()
)
I need to display both lines — the blue and the black — even when I select a subset of closed projects through filtering.
How can I make sure that the black line (representing all closed projects) remains visible when I apply filters on closed projects?
Please note that all the measures I use on the X and Y axes come from different tables.
This is the code I currently use for deneb:
{ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "width": 600, "height": 400, "padding": 5, "data": { "name": "dataset" }, "params": [ { "name": "xParam", "value": "Area_Module_2", "bind": { "input": "select", "options": [ "Area_Module_2", "Volume_Module", "GrossWeightMeasure_ModuleReport", "OperativeWeightMeasure_FacilityReport", "Eq Gross DryT", "Eq Gross Operating (t)" ], "labels": [ "Total Area (m²)", "Total Volume (m³)", "Gross Dry Weight (t)", "Gross Operating Weight (t)", "Eq Gross Dry Weight (t)", "Eq Gross Operating Weight (t)" ], "name": "X Axis" } }, { "name": "yParam", "value": "TotalGrossDryWeight", "bind": { "input": "select", "options": [ "TotalGrossDryWeight", "TotalGrossOperativeWeight" ], "labels": [ "Gross Dry Weight (t)", "Gross Operative Weight (t)" ], "name": "Y Axis" } } ], "layer": [ { "transform": [ { "filter": "isValid(datum[xParam]) && isValid(datum[yParam])" }, { "calculate": "datum[xParam]", "as": "xField" }, { "calculate": "datum[yParam]", "as": "yField" }, { "calculate": "xParam + ' = ' + datum[xParam]", "as": "X" }, { "calculate": "yParam + ' = ' + datum[yParam]", "as": "Y" } ], "mark": "point", "encoding": { "x": { "field": "xField", "type": "quantitative", "title": { "expr": "switch(xParam, 'Area_Module_2', 'Total Area (m²)', 'Volume_Module', 'Total Volume (m³)', 'GrossWeightMeasure_ModuleReport', 'Gross Dry Weight (t)', 'OperativeWeightMeasure_FacilityReport', 'Gross Operating Weight (t)', 'Eq Gross DryT', 'Eq Gross Dry Weight (t)', 'Eq Gross Operating (t)', 'Eq Gross Operating Weight (t)', 'Unknown')" } }, "y": { "field": "yField", "type": "quantitative", "title": { "expr": "switch(yParam, 'TotalGrossDryWeight', 'Gross Dry Weight (t)', 'TotalGrossOperativeWeight', 'Gross Operative Weight (t)', 'Unknown')" } }, "color": { "field": "ProjectType", "type": "nominal", "scale": { "domain": ["Closed", "Opened"], "range": ["#1f77b4", "#d62728"] } }, "shape": { "field": "ProjectType", "type": "nominal", "scale": { "domain": ["Closed", "Opened"], "range": ["circle", "triangle"] } }, "tooltip": [ { "field": "X", "type": "nominal", "title": null }, { "field": "Y", "type": "nominal", "title": null }, { "field": "RevisionNum", "type": "nominal", "title": "Revision" }, { "field": "facility_code", "type": "nominal", "title": "Facility Code" }, { "field": "ProjectType", "type": "nominal", "title": "Project Type" } ], "opacity": { "condition": { "test": "datum.ProjectType === 'Closed'", "value": 0.6 }, "value": 1 } } }, { "transform": [ { "filter": "datum.ProjectType === 'Closed' && isValid(datum['Area_Module_2']) && isValid(datum['TotalGrossDryWeight'])" }, { "calculate": "datum['Area_Module_2']", "as": "xField" }, { "calculate": "datum['TotalGrossDryWeight']", "as": "yField" }, { "regression": "yField", "on": "xField", "method": "linear" } ], "mark": { "type": "line", "color": "black", "strokeDash": [4, 4], "strokeWidth": 2 }, "encoding": { "x": { "field": "xField", "type": "quantitative" }, "y": { "field": "yField", "type": "quantitative" } } }, { "transform": [ { "filter": "datum.ProjectType === 'Closed' && isValid(datum[xParam]) && isValid(datum[yParam])" }, { "calculate": "datum[xParam]", "as": "xField" }, { "calculate": "datum[yParam]", "as": "yField" }, { "regression": "yField", "on": "xField", "method": "linear" } ], "mark": { "type": "line", "color": "#1f77b4", "strokeDash": [4, 4], "strokeWidth": 2 }, "encoding": { "x": { "field": "xField", "type": "quantitative" }, "y": { "field": "yField", "type": "quantitative" } } } ] }
Thanks
Solved! Go to Solution.
Hi @Fern_21,
Thank you for reaching out to the Microsoft fabric community forum. I reproduced the scenario again, and it worked on my end.
By default, slicers in Power BI affect all visuals on a page. To achieve the expected behavior where visuals are not impacted by slicers, we created a duplicate page and used bookmarks as a workaround.
I am also including .pbix file for your better understanding, please have a look into it:
Hope this helps clarify things and let me know what you find after giving these steps a try happy to help you investigate this further.
Thank you for using the Microsoft Fabric Community Forum.
Hi @Fern_21, 
Thank you for reaching out to the Microsoft fabric community forum. Also, thanks to @Shahid12523, for his inputs on this thread. I reproduced the scenario, and it worked on my end. I used my sample data and successfully implemented it.
I am also including .pbix file for your better understanding, please have a look into it:
Hope this helps clarify things and let me know what you find after giving these steps a try happy to help you investigate this further.
Thank you for using the Microsoft Fabric Community Forum.
Hi @v-kpoloju-msft !
Thank you for your help. I'm in the same situation. What I would like to further implement is a black line that represents all closed projects, regardless of which closed project is currently filtered. Also, when a closed project is selected, the black line and the open projects should not disappear.
Hi @Fern_21,
Thank you for reaching out to the Microsoft fabric community forum. I reproduced the scenario again, and it worked on my end.
By default, slicers in Power BI affect all visuals on a page. To achieve the expected behavior where visuals are not impacted by slicers, we created a duplicate page and used bookmarks as a workaround.
I am also including .pbix file for your better understanding, please have a look into it:
Hope this helps clarify things and let me know what you find after giving these steps a try happy to help you investigate this further.
Thank you for using the Microsoft Fabric Community Forum.
Hi!
Thank you for your solution. Is it absolutely necessary to use two pages for it to function properly?
Furthermore, the second chart should display the selected project in a highlighted state. To clarify: when project_id F1 is selected on the filtered page, the unfiltered page should still show the current chart (which is correct), but with F1 visually emphasized to indicate the selection.
Thanks
Hi @Fern_21,
Thank you for the follow-up question.
Yes as part of workaround this is the only way to show the constant black line in the chart using bookmarks. 
Thank you for using the Microsoft Fabric Community Forum.
Hi @Fern_21,
Hope you had a chance to try out the solution shared earlier. Let us know if anything needs further clarification or if there's an update from your side always here to help.
Thank you.
Hi @Fern_21,
Just checking in to see if the issue has been resolved on your end. If the earlier suggestions helped, that’s great to hear! And if you’re still facing challenges, feel free to share more details happy to assist further.
Thank you.
Hi @Fern_21,
Just checking in to see if the issue has been resolved on your end. If the earlier suggestions helped, that’s great to hear! And if you’re still facing challenges, feel free to share more details happy to assist further.
Thank you.
@Fern_21 Hey,
you need to adjust the data transformations used for creating the trend lines. Here's a brief explanation of how you can achieve this:
- Black Line (All Closed Projects):
- Use a transformation step outside the filtering scope to ensure it always includes all closed projects. This step should not be affected by visual-level filters.
- Store the required data for all closed projects in a separate data preparation step, separate from the filtered data.
- Blue Line (Filtered Closed Projects):
- This trend line can use the current filtered data – i.e., the subset you're selecting.
Adjust the transformation layers in your Deneb code as follows:
Thanks
Harish M
Create a separate unfiltered table in Power BI (e.g., AllClosedProjects)
✅ Add it as a second dataset in Deneb
✅ Use that dataset for the black trend line layer
This way, filters affect only the blue line, while the black line always shows all closed projects. Clean, dynamic, and filter-proof.
Hi @Shahid12523 !
How do I create AllClosedProjects? The dataset I need contains measurements to use on the x-axis and y-axis and they are part of different tables, connected to each other via the facts table. For example, I have Area and Volume present in modules and total gross weight present in items. The project type to define open or closed projects is present in facilities. Could you give me an example?
Thanks
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.