Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jeseng
Helper III
Helper III

Comparing line chart

Hi,
I have a line chart, my users choose an area from a slicer. The line chart then shows the population growth for this area.
What I want is to show a second line, an other area (Göteborg) to compare to the chosen one. So I want one line that the user choose and one that is always there. But it doesnt seem to be possible to preselect a locked value?
Comparison line chart.PNG

12 REPLIES 12
Anonymous
Not applicable

Hi  @jeseng  ,

According to your description, I create this data:

v-yangliu-msft_0-1612486710169.png

 

Here are the steps you can follow:

1. Create measure.

Locked in (Gothenburg) development:

Gothenburg region all =
SUMX(FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])),'Table'[people])

User selected:

User chooise =
var _select=SELECTEDVALUE('Slicer'[Region])
var _1=CALCULATE(SUM('Table'[people]),FILTER('Table','Table'[Gothenburg region]=_select&&'Table'[Year]=MAX('Table'[Year])))
return _1

2. Result.

v-yangliu-msft_1-1612486710175.png

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi  @jeseng  ,

According to your description, I create this data:

Main Table:

v-yangliu-msft_0-1612312655786.png

Slice Table:

v-yangliu-msft_1-1612312655788.png

Here are the steps you can follow:

1. Create calculated column.

Year = YEAR('Table'[date])

2. Create measure.

A =
var _1=
CALCULATE(SUM('Table'[people]),FILTER('Table',[region]="A"))
return
IF("A" in SELECTCOLUMNS('Slicer',"1",[Region]),_1,BLANK())
B =
var _1=
CALCULATE(SUM('Table'[people]),FILTER('Table',[region]="B"))
return
IF("B" in SELECTCOLUMNS('Slicer',"1",[Region]),_1,BLANK())

3. Place Year in Axis, measure A and measure B in Values, and place Region and Sex in different slicers

4. Result.

When we select Region A, only the data of A will be displayed in the line chart, and it will change with the selection of the slicer Sex

v-yangliu-msft_2-1612312655790.jpeg

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much for taking your time with this!! But I seem to be explaining poorly 😉
I live in Gothenburg, we have 36 sub areas. I want a line chart where I can ALWAYS see the development for Gothenburg and then from a slicer choose ONE sub area. So that I always show 2 line, one that is locked (Gothenburg) and one that the user chooses.
There will also be a slicer for Age and Gender but that doesn't seem to be the main problem.
I CAN solve this in my datatable by creating a new column with the values for Gothenburg and put this on every row, so that every sub area have two values, but this will be difficult to update since I plan to collect the data via API....

Best Regards,
Jessica

Tahreem24
Super User
Super User

@jeseng ,

Create a measure like below for a constant line:

Measure = CALCULATE(SUM('Table'[Growth]),FILTER(ALL('Table'),'Table'[AreaName]="Göteborg"))
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Hi again,

When I removed the variable from "legend" I was able to put my measure in "values". The thing is, I dont want a constant line 🙂 I want to show the values for "Göteborg" as well as one more area, which my user can select from a slicer. My user also chooses Age and Gender in slicers.

Where do I put this measure?
As you can se below:
I have YEAR om my axis, then the AREA (which is in i slicer that my user can choose one area from) and the my value (from a column i my datatable) that is growth in percentage. Where do I put the measure?Skärmklipp.PNG

@jeseng ,

Which visual are you using?

I can able to add measure under values option.

Capture.PNG

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

I noticed that it has to do which Legend, if I have a value i "Legend", I can only put one value in "Values"... to bad.

amitchandak
Super User
Super User

@jeseng , Try a measure like

calculate([measure], filter(all(Table[area]), table[area] ="Göteborg"))

 

But this will work better if the area is in a different table joined to this table

 

calculate([measure], filter(all(area), area[area] ="Göteborg"))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Okey, and where do I put this measure? 🙂

@jeseng , You original measure and [measure] and this new measure both should be added to values/line

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hm, I can only have ONE value, in value?
As you can se below:
I have YEAR om my axis, then the AREA (which is in i slicer that my user can choose one area from) and the my value (from a column i my datatable) that is growth in percentage. So I dont have any other measures.

Skärmklipp.PNG

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.