March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I'm creating a histogram using R (specifically, ggplot). The three columns I'm feeding the visual are:
The data source contains a row for every single connection that occurred for all devices whose ID is stored in the id column. I just want to create a histogram that tells me the number of days each ID had a connection. The code to accomplish this is:
##### Below added by Power BI; cannot be modified #####
# Create dataframe
# dataset <- data.frame(reportDate, id, class)
# Remove duplicated rows
# dataset <- unique(dataset
##### Above added by Power BI; cannot be modified #####
library(ggplot2) library(plyr) # Group by ID and count how many reportDates each one has DateCount <- ddply(dataset, .(id), summarise, Count = length(unique(reportDate))) # Plot ggplot(DateCount, aes(x=Count)) + geom_histogram(binwidth = 1, color="black", fill=rgb(1, 184, 170, maxColorValue=255)) + theme_bw() + xlab("Days Seen")
This works well, and produces the following result (I added a slicer so I can filter by a particular class):
Now let's say I add a measure to my report that's just a string:
Measure = "test"
If I add this column to the R visual, my intuition is that a column called Measure will be added to the dataset variable, but the rest of the columns should not change in any way, since the Measure column will just contain "test" for every row. However, once I add the Measure, the visual changes drastically:
Why is my intuition wrong? If I let the visual print how many rows dataset has, the values differ between both graphs. Without Measure it's 8740, and with Measure it's 14341. Why are these values different?
Thanks!
Thank you for the responses. I've found the issue, and it appears to be a bug. I have successfully replicated it and linked to a file with the repro.
I have an additonal fact table with an individual row per ID. I have a Report-level filter set in place for one of the columns in this table. It seems that the filter is completely ignored when I add this measure. This only occurs if the filter is in another table (if it's in the same one, it works fine). In addition to Slicers, Visual-level, Page-level, and Report-level face this issue.
This is a sample .pbix file that replicates this issue. This file has two tables: BugTable and AdditionalTable. BugTable has the reportDate, id, and class. AdditionalTable classifies each ID to a different group (the data is filtered to display only the first group). The filter works fine, but if you add the AddToRVisual measure to the R visual, the filter will be ignored.
Is there any location where I can report this (internally or externally), besides just hoping this post gets noticed by the appropriate people?
Yes, I also noticed the same issue.
In my case, all attribute of which I want to make Histogram are in single column and I filter them by a slicer (select just one attribute at a time), it works fine.
Then I want to create dynamic binning, so I created a Calculated table with generate series function and use a single number with the help of a measure (selectvalues function).
As soon as I add this measure to the R Visual, graph takes long time to load. Upon investigation, I found that number of rows visible to the R visual increases dramatically, later found that no filter/slicer works on main column of data used for histgram and exposing complete table to R, instead of filtering single attribute. I think its becuase of no relationship with the measure or some bug.
The alternate solution might be to not use the attribute slicer and unpivot the attribute column, but thats not practical for me, so I need another solution.
and it is not the case with R visual, but can be seen with a table/any visual. So it is most likely a relationship issue.
Hi,
You can go to https://ideas.powerbi.com/forums/265200-power-bi to provide a feature request.
Best Regards
Alex
Hi,
I can’t reproduce your error. It works fine for me.
Before adding Measure = “test”
After adding Measure = “test”
Graphs above looks the same. Add after adding “write.csv(dataset, file = "filepath/MyData.csv")”, I can see that the both result are the same. Please verify your r script if there are other codes that influenced the result of “count”. Also please test with other chart visuals to see if value changes after adding that measure.
Best Regards
Alex
@fedpar i think easiest way to find out what's going on is to export out dataframe that R visuals create by default. So I would suggest you create two R visuals one with measure and one without and then in R script editor type in code as below which will export out dataframe to csv file and then check.
write.csv(dataset, file = "filepath\MyData.csv")
When you run this in R script editor it will create csv file and then you can check the contents.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
User | Count |
---|---|
90 | |
89 | |
85 | |
73 | |
49 |
User | Count |
---|---|
169 | |
144 | |
90 | |
70 | |
58 |