cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
way0utwest
New Member

Compare two sets of data

This is probably simple to do, but I'm struggling a bit to compare two sets of data that have similar structures in a single chart.

 

I'm obfuscating, but let's say I've got a set of data for person a, which is something like this:

 

TimePeriod, Weight

1, 190

2, 192

3, 195

4, 194

5, 196

 

I've got similar data for Person B.

TimePeriod, Weight

1, 180

2, 182

3, 185

4, 184

5, 186

 

If I want to somehow compare these two in a chart, showing two lines, I can't quite figure out how to pull this together. Certainly I can add columns with percentages or other normalizing values, but to get the data from two sets, with a common column, whether integer or time, doesn't seem to work for me.

 

Ideas?

1 ACCEPTED SOLUTION

Try and merge the data together in Power BI or upstream so it looks like this:

 

TimePeriod, WeightA, PersonID

1, 190 ,A

2, 192 ,A

3, 195, A

4, 194, A

5, 196, A

 1, 180,B

2, 182, B

3, 185, B

4, 184, B

5, 186, B

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

7 REPLIES 7
B129
Continued Contributor
Continued Contributor

Hi @way0utwest,

 

   you want to compare these two dataset in a chart showing two lines right?

Because if you do not want to merge the two dataset, you can just add a relationship between them:

 

compare_dataset (2).png

 

Then using the Line Chart visualization you can plot this:

 

compare_dataset (1).png

to observe the changes between them.

Let me know if it works.

 

#I'M Not An Expert#

valQuentine
Frequent Visitor

Can you toggle ON/OFF the compared charts? Say, I want to show one dataset in the same chart and compare it with another (with the option to turn it ON/OFF).

pqian
Microsoft
Microsoft

We don't support plotting unrelated data sets in one chart (probably doesn't make a lot of sense in BI), so you can do what @SqlJason said to combine your data into one table, or create a relationship between the two sets (using TimePeriod as key) and plot them on a line chart.

Try and merge the data together in Power BI or upstream so it looks like this:

 

TimePeriod, WeightA, PersonID

1, 190 ,A

2, 192 ,A

3, 195, A

4, 194, A

5, 196, A

 1, 180,B

2, 182, B

3, 185, B

4, 184, B

5, 186, B

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

Thanks, I tried that, but couldn't get it to visualize or slice correctly.

 

The merge worked, and I'll mark that as a solution.

 

 

To add more detail, in case I'm missing something, I really had three fields. The data was like this:

 

Table Mark

Year, Person, Measure

1, Mark, 23

2, Mark, 24

3, Mark, 18

 

Table Steve

Year, Person, Measure

1, Steve, 22

2, Steve, 26

3, Steve, 19

 

When I try to create a relationship on year, it says I have this, but I can't get both items on the same chart. If someone has a good tutorial or blog link, I'd appreciate it. I don't like the merge/append

 

SqlJason
Memorable Member
Memorable Member

Ideally, you should append those 2 datasets, with one more column specifying person. So now, your table structure will look like

Person, TimePeriod, Weight.

 

Once you have this, you can put the TimePeriod on axis, Person on Series/Legend and Weight on Values, and then you will get a line chart that can be used for comparison

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.