Skip to content

RS-20371, RS-20850: Fix warnings and checks on filters and weights#86

Merged
chschan merged 7 commits intomasterfrom
RS-20371
Feb 23, 2026
Merged

RS-20371, RS-20850: Fix warnings and checks on filters and weights#86
chschan merged 7 commits intomasterfrom
RS-20371

Conversation

@chschan
Copy link
Contributor

@chschan chschan commented Feb 18, 2026

There have been several bug reports about warnings on filters popping up unnecessarily, but there are cases when it is appropriate to show warnings, so I've tried to preserve the warnings but just fixing the conditions when they are shown.

For example, when a R viz references a table on a different page, and page filters are applied on the viz, but not on the referenced table, then a warning should be shown.

###########################################################################
# 2. Filters the data and/or removes missing values
###########################################################################
if (isScatter(chart.type) && !is.null(input.data.raw) && containsQTable(input.data.raw))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we distinguished whether filters should be applied to the X/Y/Z coordinates dropbox by checking whether it was a raw variable or a summary table based on the attributes. But the dropbox controls now accept calculations, and they are often missing attributes if the use is only extracting a column etc, so we just check lengths

"To apply filters you need to instead filter the source data that is being visualized.")
"To apply filters you need to instead filter the source data that is being visualized.")
tb.desc <- attr(x, "basedescription")
if (is.null(tb.desc) || tb.desc$FilteredProportion == 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra check on tb.desc$FilteredProportion == 0 is unnecessary because of the check in the else if block. It is also causing the warning to show when it shouldn't. For example when Awareness - Coca-Cola is set as a filter, because of 100% of respondents were aware of this brand, the filtered proportion was 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the example given in RS-20371, most of the warnings are caused by https://github.com/Displayr/q/pull/23862/changes#diff-6f96a7535848bb56e74401d118d945905d6eb60a726c1904399d5953c4f42a89L4857 but this is the cause of the warning in RS-18209.

@chschan chschan requested a review from JustinCCYap February 19, 2026 03:37
R/preparedata.R Outdated
if (isScatter(chart.type) && !is.null(input.data.raw) && containsQTable(input.data.raw))
# Ignore filter if the scatterplot input is not raw variables.
# The input can be a Q summary table or some other type of calculation
use_filter <- length(subset) > 1 && NROW(subset) == NROW(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be use.filter instead

R/preparedata.R Outdated
# Ignore filter if the scatterplot input is not raw variables.
# The input can be a Q summary table or some other type of calculation
use_filter <- length(subset) > 1 && NROW(subset) == NROW(data)
if (!use_filter && isScatter(chart.type))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems strange that we only need to do this for scatter. What happens with the other charts when use_filter is FALSE?

Copy link
Contributor Author

@chschan chschan Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only need to ignore filters for scatter because its the only chart where the dropbox controls for the input.data.raw can also accept non-variables


processPastedData <- function(input.data.pasted, warn, date.format, subset, weights)
{
if (length(subset) > 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example in the bug appears to be for input data, not pasted data. Do you need to make the same change to processInputData?

If thats the case, will we ever show a warning about filters not being applied? I guess this could be a solution but it means we no longer warn when we should. But Sam made the point about applying a fix to the q repo https://numbers.atlassian.net/browse/RS-20371?focusedCommentId=170229. I imagine we would disable applying page filters to all R calcs that do not have a raw data input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've restored the warning for pasted data. I initially did think about just removing all the warnings, but after some more thinking I think we should keep them where possible.

The fix in the q repo works by not applying the filter on the R viz, only on the nested table, but this is causing some inconsistencies so I am going to revert that: https://github.com/Displayr/q/pull/23862. We also don't really want to add warnings via q because its a bit hard to figure out when the warnings can be turned off.

@JustinCCYap
Copy link
Contributor

I'm trying to figure out what the effect of these changes are. Based on my understanding:

RS-20850 Labelled Scatter Plot returns error when filter is applied

https://numbers.atlassian.net/browse/RS-20850

  • We no longer show a warning for labeled scatterplots when the length of the filter differs from the inputs

RS-20371 Visualizations incorrectly show filter/weight warnings when filters are applied at folder or page level

https://numbers.atlassian.net/browse/RS-20371

Is that correct?

@chschan
Copy link
Contributor Author

chschan commented Feb 22, 2026

Yes, I think most of the warnings in the document in RS-20371 will be fixed by https://github.com/Displayr/q/pull/23862/changes.

But some of the warnings in https://numbers.atlassian.net/browse/RS-18209 will be fixed by removing the check in PrepareData for attr(x, "basedescription")$minProp == 0

@JustinCCYap
Copy link
Contributor

But some of the warnings in https://numbers.atlassian.net/browse/RS-18209 will be fixed by removing the check in PrepareData for attr(x, "basedescription")$minProp == 0

Are you referring to this:
https://github.com/Displayr/flipChart/pull/86/changes#diff-1fa145fd3255b55efc51409cb6bde614753d16b220e65fdbea73e7ab3822d76cL1061

@JustinCCYap
Copy link
Contributor

Filters were originally excluded from items with nested items in https://github.com/Displayr/q/pull/20846 to compensate for the fact that warnings about filters were being incorrectly shown on some visualizations. This is now fixed in #86

How does this PR fix the old issue that https://github.com/Displayr/q/pull/20846 was meant to fix?

@chschan
Copy link
Contributor Author

chschan commented Feb 23, 2026

This PR (particularly https://github.com/Displayr/flipChart/pull/86/changes#diff-1fa145fd3255b55efc51409cb6bde614753d16b220e65fdbea73e7ab3822d76cL1061) stops some incorrect warnings about Filters being ignored from being shown when the referenced/nested table does in fact have the appropriate filter applied.

@JustinCCYap
Copy link
Contributor

This PR (particularly https://github.com/Displayr/flipChart/pull/86/changes#diff-1fa145fd3255b55efc51409cb6bde614753d16b220e65fdbea73e7ab3822d76cL1061) stops some incorrect warnings about Filters being ignored from being shown when the referenced/nested table does in fact have the appropriate filter applied.

Does it fix the original example in https://numbers.atlassian.net/browse/RS-19614

Copy link
Contributor

@JustinCCYap JustinCCYap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chschan chschan merged commit 0ec668c into master Feb 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants