Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Regular Visitor

Problem Creating Box plot with R (wrong mean and median)

Good morning!


I am encountering some issues while trying to create a box plot with R. 

The plot loads on the screen, i..e no problems with libraries; however, the mean and median are completely wrong.





For the far left box, the mean is supposed to be 4.3, yet, as you can see it is closer to 50.


I believe the problem lies with R determining how to calculate mean and median with the raw data. Although, it appears the dots on the box plot are correct, i.e. they correspond with the numbers in the raw data.

For clarity, the raw data contains about 200,000 rows and each row contains a number (IND_CASE_COUNT) and a category (PCTY_CD). 


Any help on this would be appreciated. I ran into a similar problem with one of the downloadable visuals, as it produced a box plot but it was not producing the correct mean and median. 

Thank you 🙂


Regular Visitor

I am not sure if we are allowed to bump messages. I would appreciate some help, even if it means posting this in a different forum. Thanks!

FYI boxplots do not display means! The lines in the boxplots you posted are the medians of each group and each box stretches between the 1st and 3rd quartiles of your data. So, first thing I'd suggest is checking if some medians you calculate in your data are matching up with the boxplots. If you're finding the box plots are still not lining up with your expectations, the only Power BI element I could see contributing to the issue is if you're summarizing the fields you added to the visual or something. You could also just build the plot in R (outside of PBI) and see if they are the same to confirm whether PBI is affecting the output.


Hope this helps!

Helpful resources

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.