I am using the within() function to query an underlying feature class. Then calculating fields based on the values pulled from the within(). If the feature is an odd shape it will return nothing or the wrong value. I am using this syntax, within( querylayer ,centroid($feature)). Sometimes the centroid is outside of the feature.
In the image below, the within function is using the red point to query the 31E33AD polygon. I need the function to query the 31E33 polygon using the green point. If I remove the centroid function, within() returns nothing.
Red is the centroid used by the within() function.
My suggestion is to create a function that uses a center point within the selected feature. Or fix the centroid function to place the point within the feature.