I have the following data in Power BI.
X | Y
10 | 2
11 | 3
12 | 4
13 | 5
14 | 6
15 | 7
15 | 10
Both X and Y were set to Don't Summarize.
Then I created a measure for Y as follows:
newY = SELECTEDVALUE(Sheet6[Y])
The reason for the measure is that I don't want to do any calculation (sum, count...) when creating the line chart.
Just want to plot the values on the chart.
So using the solution proposed here: How to create a basic line chart in Power BI?
Then created a line chart dragging X to the x-axis and newY to the Y-axis in the Visualizations pane.
This is the resulting chart:
Question is:
Why didn't it plot (15, 7) and (15, 10) continuing the line until there?
I would like them plotted and have the result be like this:
This is just the way PowerBI and DAX works. SELECTEDVALUE() returns a single value only if a single value is in the context. At x = 15, you have two values in context (7 and 10) hence SELECTEDVALUE() will return blank. I know you're frustrated that PowerBI can't operate the same as Excel but the native line chart is a bit limited and I know the team are working on updates to it. You can still do what you want in Power BI but you will need to use Deneb.
For example, here is a Deneb line chart which does what you like:
Created with this code (Vega-Lite) which you put into Deneb.
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"X": 10, "Y": 2},
{"X": 11, "Y": 3},
{"X": 12, "Y": 4},
{"X": 13, "Y": 5},
{"X": 14, "Y": 6},
{"X": 15, "Y": 7},
{"X": 15, "Y": 10}
]
},
"mark": "line",
"encoding": {
"x": {"field": "X", "type": "quantitative"},
"y": {"field": "Y", "type": "quantitative"}
}
}