cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
asayat Frequent Visitor
Frequent Visitor

Legend do not aggregate values

I want to show stacked bar chart that colors values' category but does not aggregate the data.

 

The dataset in use:

STROrderCatIdSize
bird1a500021
bird2b500061
cat1a500011
cat2b500041
cat3b500051
cat4b500091
dog1b500031
dog2a500071
dog3a500081


I need to show each Size value in each STR colorized by Cat and order by Order.

Here's my attempt using legend - cat

pwoerbi.png

 

I want the final result be something like this:

rscript.png

The last graph was generated via Rscript:

library(ggplot2)
library(data.table)
library(plotly)
db<-data.table(dataset)
setorder(db, Order)
ggplot(db, aes(x=STR,label=Order, y=Size) )+
  geom_bar(aes(fill=Cat),stat="identity", color="blue")+coord_flip()+
  guides( color=FALSE)+  geom_text(size = 3, position = position_stack(vjust = 0.5)) 

The main problem is that R graphs are not interactive, so need to use powerBI visual option.

3 REPLIES 3
Microsoft v-huizhn-msft
Microsoft

Re: Legend do not aggregate values

Hi @asayat,

You can create R visual in Power BI desktop.

First, you need to get data, create a resource table, please see the following screenshot.

1.PNG

Second, select the R visual, select all the column as dataset. Type your R script and run it, you will get expexted result.

2.PNG

Please feel free to ask if you have any other problem.

Best Regards,
Angelia


 

asayat Frequent Visitor
Frequent Visitor

Re: Legend do not aggregate values

Dear Angelia@v-huizhn-msft, thank you for your response!

 

The problem with R visual is that it's not interactive with other visuals. There is a need to have a plot as described above and click to any bar and get more specific information for that cell in other tabular visual. It can't be done by simply R visual.

 

Microsoft v-huizhn-msft
Microsoft

Re: Legend do not aggregate values

Hi @asayat

I understand your requirement now, while there is no such visual in Power BI desktop. After research, I find a custom visual (Table Sort), which is same with what you want but closer to. Please see the following screenshot. For same STR, cat a and b are shown in different colors. 

1.PNG

Thanks,
Angelia

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)