Hello,
I am using XamDataGrid and not able to understand how the Top 10 filter works. I am using it on the DateTime field and I have attached a sample where in it has two sets of data. It does work with one and not with the other. There is only difference in date values and nothing else in the sample data. In the work set, filtering out Top 10 clearly shows only 10 rows out of 15, where as in the non working set, setting the filter has no effect and it continues to show all the 15 rows. Could you please check and let me know whats wrong and how its suppose to work.
Thanks
Himmat
Hello Himmat,
Thank you for contacting us.
I have been looking into your question and into the sample application, that you have provided.
The 'Top 10' filter gets the 10 highest values. For example if you have a number field it would get the numbers from 6 to 15.
In case of the first XamDataGrid and the 'working' List - you have 15 different dates and the XamDataGrid takes the once from DateTime.Now.AddDays(5) to DateTime.Now.AddDays(14) - the 10 'highest' dates.
In the case of the second XamDataGrid the DateTime Field has only two values - DateTime.Now and DateTime.Now.AddDays(1). This is why all 15 values are displayed.
Please do not hesitate to let me know if you have any further questions on this matter.
Thanks Gergana for the response. Sorry to say I am still not following the logic being used in the Top 10 filter. From what I am gathering you are pointing towards using top 10 distinct values and then showing all the rows that matched the top 10 distinct values. Since in the earlier sample data, the second set had only 2 distinct values, hence all 15 rows were displayed, but in the first set there were more than 10 distinct values, hence it filtered out.
But now I have reattached the sample with bit different data. I have two sets of data, where in the first set I have 9 distinct date values and in the second set I have 2 distinct date values. It still does filter out in the first set, but not in the second. Any idea why is that so. Appreciate your explanation.
Himmat.
The ‘Top 10’ filter does not take the bottom or the top 10 items. It takes the 10 items, that have the biggest value.
You can check that better when there is an integer field with random values in it.
I have modified the sample application for you to show you this functionality. You can add ‘Top 10’ filter for the first Field and see, that only the biggest values are taken. For the second XamDataGrid there only 0 and all of them are shown as all values are equal.
For the second XamDataGrid, where you have only two distinct values – it takes the two distinct values (DateTime.Now(01/07/2016) and DateTime.Now.AddDays(1)(01/08/2016) ). Then for the other values it cannot say which one is bigger (01/07/2016 or 01/07/2016). As these values are equal it shows them all. The same goes for the second distinct value.
Hello Gergana,
Thanks for the response. Wanted to get some more understanding on the working. From what I am gathering the way the 'Top 10' is working is as follows
1. Look for top 10 distinct values in the result set
2. Print out all values matching the top most item
3. See if the count is > 10 then stop else look for the next biggest item and display ALL the values matching it.
As a result of this logic, it can very well display more than 10 rows. I have modified the sample to just have a grid with integer column in there.
In the first set I have 15 rows with 2 distinct values (1 and 2). I have 7 rows of value 2 and 8 rows of value 1). In this case it displays all 15 rows after applying the 'Top 10' filter. Logic which is running is
1. Look for top 10 distinct values in the result set - (1 and 2)
2. Print out all values matching the top most item - i.e. 2. Hence all 7 rows of 2 are being displayed
3. See if the current result set count is > 10. => False => Print out all the values matching the next biggest item. Here its not checking that if the going to be added result set can cause the count of the total result set to go beyond 10 rows. Hence its just displaying all the values matching value 1 which happens to be 8 rows. Hence the total result set of 15 rows is being displayed
Further to illustrate that this is the logic being used - I have the second result set which again has 15 rows to start off with. Here it has three distinct values (3,2,1).
1. Look for top 10 distinct values - (3,2,1)
2. Filter out all values matching the top most value i.e. 3 - Hence all 7 rows of 3 are being displayed
3. Next biggest item is 2 - This has 5 rows in there - Since the current result set count is 7 which is < 10, it picks and displays all the rows matching the next biggest which happens to be 5 rows and now the result set count is 12 rows.
Please let me know if this is the way its working.
If so, we may not be able to use this as from the users perspective, if they are applying a filter of top 10, they would either expect all the rows matching the top 10 values to be displayed or otherwise only 10 rows to be displayed matching the top values. Currently its giving a mix of the two. Could you please suggest how to get this fixed.
I'm sorry you didn't receive a reply earlier on this. The operand is working as it was designed. The filtering does not operate on the entire list but instead is used to filter in/out each item based on how the field value for the data item compares with the operand value so it is not possible for it to take the top 10 data items. However as you point out it isn't taking the top 10 unique values either. Instead what it does it take all the (non-empty) values from the items, sorts that and then takes the nth (10th in this case) item value and cache that - i.e. it's taking the value of the 10th item - essentially in an effort to get the top 10 items (or at least all items whose value matches the top 10 item values). Then when determining if each item is a match or not, it just compares the value for the item being evaluated against that cached value. If you want it to operate based on the top 10 unique values then you would have to create your own custom operand (e.g. derive a class from SpecialFilterOperandBase and assuming you want to replace ours then register that using SpecialFilterOperands.Register) or override the match handling (e.g. setting the FilterEvaluator of the FieldSettings to a custom IFilterEvaluator implementation that handles the filter). For the latter you would probably try to cast the rhs to a SpecialFilterOperandBase, check the Name of the operand and then implement your filtering logic presumably calculating the top/bottom 10 unique values. I've attached a sample that does the former as well as put a stub in for the latter although the implementation would be similar to the former in terms of the match implementation.