cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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 Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (3,946)