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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lushd
Frequent Visitor

Multi variable scatter plot

Hi Community,

 

I have a dataset of shipping voyages with columns for Date, Port, Shipping company, loading time, discharge time, etc. 
One useful visual is a scatterplot with loading time and discharge time on the X and Y axis respectively, where each dot represents a single port. Power BI automatically averages the load/discharge time for each visit to a particular port to correctly place the dot, and the graph works perfectly with no issues. With this the end user can easily see which ports are the most and least efficient. 

 

I have a second graph which is identical in every way including scale, but each dot represents a shipping company rather than a port. This also works perfectally with no issues. 

 

What I want to do is combine these into a single chart where each port dot shows up as blue, and each company dot is red. I see these kinds of graphs all the time (example from 30 second google search included below), but it appears to be impossible on Power Bi. In each case, the category ('port', 'company') shows up in the 'details' field on the visualizations pane. I am able to drag the second catagory in, but rather than displaying all the data at once, this creates a two level graph where I can toggle between the two- which is not what I want. 

 

Given how often I see these kinds of graphs, I just can't imagine it's really not possible. What am I missing, or is there another visual I can download that allows this? 


Thanks so much in advance.

scatter-plot-options-2.png

(Example of what I'm trying to do)

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @lushd ,

 

Please try the following steps:

 

1. Createa a new table with Legend type (Port and Company) for slicer.

2. For dynamic Y-axis:

Measure = 
SWITCH(MAX('ForSlicer'[Legend]),
"Port",CALCULATE(MAX('Table'[discharge time]),FILTER('Table','Table'[Port]=MAX('Table'[Port]))) ,
"Company", CALCULATE(MAX('Table'[discharge time]),FILTER('Table','Table'[Company]=MAX('Table'[Company]))))

3. Create a rank measure for conditional formatting:

For conitional formatting = 
SWITCH(MAX('ForSlicer'[Legend]),
"Port",RANKX(ALL('Table'), CALCULATE ( MAX ( ( 'Table'[Port]) ) ),,ASC,Dense) , 
"Company", RANKX(ALL('Table'), CALCULATE ( MAX ( ( 'Table'[Company]) ) ),,ASC,Dense))

conditional.PNG

4. Add Port and Company to tooltips field.

tooltips.gif

Or unpivot the table.

https://community.powerbi.com/t5/Desktop/Custom-Visualisation-for-multiple-legends-and-values/td-p/6...

 

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

View solution in original post

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi @lushd ,

 

Please try the following steps:

 

1. Createa a new table with Legend type (Port and Company) for slicer.

2. For dynamic Y-axis:

Measure = 
SWITCH(MAX('ForSlicer'[Legend]),
"Port",CALCULATE(MAX('Table'[discharge time]),FILTER('Table','Table'[Port]=MAX('Table'[Port]))) ,
"Company", CALCULATE(MAX('Table'[discharge time]),FILTER('Table','Table'[Company]=MAX('Table'[Company]))))

3. Create a rank measure for conditional formatting:

For conitional formatting = 
SWITCH(MAX('ForSlicer'[Legend]),
"Port",RANKX(ALL('Table'), CALCULATE ( MAX ( ( 'Table'[Port]) ) ),,ASC,Dense) , 
"Company", RANKX(ALL('Table'), CALCULATE ( MAX ( ( 'Table'[Company]) ) ),,ASC,Dense))

conditional.PNG

4. Add Port and Company to tooltips field.

tooltips.gif

Or unpivot the table.

https://community.powerbi.com/t5/Desktop/Custom-Visualisation-for-multiple-legends-and-values/td-p/6...

 

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

amitchandak
Super User
Super User

@lushd , if category and port are two different columns you can have one of them in legend or other on Details.

 

If you want these as legends, You need to unpivot the data

https://radacad.com/pivot-and-unpivot-with-power-bi

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.