Filtering lotus-domino views that have multiple categories and multiple values - xpages

I am trying to design a view with multiple categories, and each document can belong to multiple categories at the same time.
For example, File A is in category:
1->a;
2
I can achieve this effect by specifying the columns as categories and access the document through various routes. However, I fail to specify which category the sub-categories belong to. This is what I am getting instead:
1->a;
2->a
The case doesn't seem too big of a difference but basically the view is returning every combination of the categories and the amount of entries can get very large.
I have tried to add the super category in front of the sub-category and try to filter out entries which the categories do not match the prefix of the sub-categories(e.g. 1,a), but I cannot find a way filter them out. Although the multiple values are shown in different entries, when I try to use the variable it extracts all the values.
Is there a way I can filter the entries based on that particular row instead of all the values? Or is there anyway I can achieve the effect through other methods? Thank you in advance.

You need to collapse Categories and subcategories into a single field. The Domino way to do this is to separate category and subcategory by backslash. So your category field would be something like:
"1\a":"2"
That ties the subcategory to the category. Or if you want to be able to find a document by subcategory only:
"1\a":"a":"2"
You then can use a little formula magic to get from the subcategory back to the main category (presuming the subcategories don't duplicate):
AllCategories := "1\a":"a":"2";
foundCategory := "a";
#Trim(#Replace(AllCategories;foundCategory:#Trim(#ReplaceSubstring(allCategories;foundCategory)));
This would return "1\a" (Note: the formula above is written is classic #Formula language, it is left as an exercise to the reader to translate that to the JavaScript formula equivalent)
Hope that helps

Related

How do I use XL Data Tables with XLOOKUP for Data Validation

I have a data table based on a query -> tblPrimaryProducts
tblPrimaryProducts has many columns, some of which are Category, SubCategory and Item.
If I were to use a filter on Category I would of course be able to see the SubCategories and Items in that Category. Likewise if I were to apply a filter to SubCategory in turn I would see a list of on the items in that specific Category + SubCategory selection. Ultimately this is the goal of data validation I am trying to implement.
There is a data entry table -> tblPackages
tblPackages has many fields, but importantly the three listed above need to be implemented in a controlled way via data validation so that each row can have the correctly selected Category + SubCategory + Item
I am unable to change the data table into an array or simple (or dynamic) named range because it will be refreshed any number of times and the column positions will potentially alter. This means that I have to use the table based naming system for both tables.
What I have so far is the following for a data validation formula using XLOOKUP:
XLOOKUP([#[Primary Category]] & [#[Primary SubCategory]], tblPrimaryProducts[Category] & tblPrimaryProducts[SubCategory], tblPrimaryProducts[Item],,0)
[#[Primary Category]] and [#[Primary SubCategory]] are fields in the tblPackages data entry table. The other fields listed come from tblPrimaryProducts. So far I have entered data by hand to test this out.
In the XL Formula window (where you can 'see' what your formula is doing while you fill in the fields) this seems to work and provides the output expected.
When I try to implement this as data validation it complains about an error in formula. If I place an INDIRECT at the beginning I get the syntax error popup. I have had issues in the past with INDIRECT that have been solved with the careful use of quotation marks. I cannot seem to find a way here to do this.
Does anyone have any ideas on how I might implement some data validation based off of a data table (as opposed to an array), or the query that the table is based on in this situation? Under normal circumstances I would use dynamic named ranges but here I cannot.
Any help or ideas greatly appreciated
In Office365 the following formula will get you the list of "Items" that satisfy the "Category" and "Subcategory" conditions.
=FILTER(tblPrimaryProducts[Item],(tblPrimaryProducts[Category]=[#[Primary Category]])*(tblPrimaryProducts[Subcategory]=[#[Primary Subcategory]]),"")
It will give you a #SPILL! error if inserted in a Table and it returns multiple items that match the two criteria. You may have to redesign your output table.
If you are intending to display just the filtered values, you can then use two dropdowns with list of categories and subcategories. The filter function can then use these cells to filter the Items from source data and display as a list below.

Create Notes view for duplicate parent documents

We have an Xpages application and recently discovered an issue where there are several Notes documents that have duplicates but the duplicates are PARENT documents too and NOT response documents. Is it possible to create a Notes view that will show duplicates where all the duplicates are parents? I know the formula for showing conflicts is the following but what about where they are all parents?
SELECT #IsAvailable($Conflict)
Expounding on my comment:
Create a view which is categorized on the first column
In the first column formula, put in criteria that you would use to determine a duplicate. This may be the Document Unique ID, or maybe another field or combination of fields.
Add a second column that contains the number 1. Then enable column totals on this column.
Now look at this view you created. With the view categories collapsed, look for any number greater that 1 to determine which documents are duplicates.
I think what you are asking is not how to identify the duplicates - but how to find out which of them are parent documents. So basically you would create a view as Steve suggests - but instead of putting a constant of 1 into the second column I would suggest putting either #DocChildren (for immediate responses) or #DocDescendants (for all responses and responses to responses).
If I understand your logic then all the ones returning 0 (zero) are child documents and those returning 1 or higher would be parent documents. Of course you could also use an item on the document in your view formula - if it only exists on the parent doc (or its value can tell that it is a parent doc)
View selection formulas act on only one document at a time. They cannot perform lookups. They have no way to compare two documents. There is therefore no possible way for a view to identify duplicates.
A view can, as per the other answers, categorize documents based on common values. If there is a single field that is supposed to be unique across all documents, you can categorize on that field. That will give you a visualization of the duplicates, but it won't filter them in or out.
The only way for a view to filter duplicates - either to show only duplicates, or to exlude duplicates - would be if you run an agent that reads all documents, looks for those that are duplicates, and marks them with a special field value - e.g., IsDuplicate = 1. Once you do that, you can create a view that selects all documents with IsDuplicated = 1, or a view that excludes IsDuplicated = 1.

How to Sort View control by Lookup column

I have two forms that are related and I would to combine them in a view control. Not that difficult. This is for a "1 to Many" type scenario.
Say I have a customer view with the columns customerID and Customer Name. Then I have a view showing the "many" documents that has the columns masterCustomerID, orderNumber, orderDate.
On the XPage I create a view control of the many documents and add the columns masterCustomerID, orderNumber, orderDate. Then I add a column in the front to do a DbLookup to pull in the actual name of the customer. Nothing too fancy really.
My question is, in this situation, where the lookup column is the FIRST column. What are the strategies to sort the view column by that column. By default it would sort by the Key Value in the order view which is likely different then the Name values.
I'm not averse to using repeat controls if that would be easier.
My first thought would be to employ TreeMaps somehow, but I don't know if that's practical in the event that there might be a LOT of documents. Maybe there's something I'm missing...
Any advice would be appreciated. Thanks
Use view with (Customer name, Customer ID) structure as main view. Then based on Customer ID populate other columns by lookup from view with structure (Customer ID, Order ID, Order date). Hence it is 1:N relationship, you can't use single view component, but two nested - repeat inside view column would do.
I hope you are aware of performance impact (orders looked up for every customer row), so don't try to show too many customers at once.

Sort Column Total

I have a view with column totals.
What I want is to sort the totals-column in a Xpages-view or repeat-control.
I am able to get the totals to display but cannot sort them.
Any suggestions?
Not very clean. I wouldn't do that in production - for performance reasons - it's a brute force solution, but it should work for fair amount of categories (up to few hundreds).
Assume the view can be used for category lookups (similar to show single category). Then all you need is list of categories in correct order - based on totals and not alphabetical order. Therefore, in first cycle, loop through all categories (use NotesNavigator with cache) and store them as pair of values - (category, totals). It may be Map[String,Double] or Set[Category] where Category is POJO with category and totals attributes. In both cases you will need your own Comparator. If your categories are hierarchical, use only top level category (sorting of tree structure is more complicated).
For example:
Australia (5)
Brazilia (10)
Chile (7)
will sort as
Brazilia (10)
Chile (7)
Australia (5)
Cache this collection in viewScope (assuming totals are "static" for short period of time, user will need to reload the page to get updated data).
Feed this collection to repeater with simple data table (or view or repeater) showing only selected category.
GUI will be a bit odd with pagers (pager for categories and pager for content of category), but you will handle this, I hope.
It's probably better to ask can this type of sorting or resorting be done in Notes rather than can it be done in XPages. If it can be done in Notes then you should be able to do the same in XPages - sometimes automatically.
XPages can only do so much with the view datasource. So if the datasource can't sort the categories by the totals then you won't be able to do this in XPages. At least not out of the box.
You might be able to do something with repeats - doing a lookup of the datasource, retrieving all documents under a certain category that has the highest total before moving on to the next category in the sequence - but it likely to become pretty complicated and not worth it in the end.
Sorry if it's not the answer you're looking for.
I will try to clarify it.
There is an categorized view. Category is for example Company name.
In the view is a column with totals, so the category has also a total.
The wish is that this categorized view will show the company category, who has the highest total at the top of the view, without losing the categorization

Sharepoint 2010 Exclusive columns?

Does anyone know a way to have two columns in a SP2010 list that are exclusive? I need to ensure that there is only a value for ONE column, not both.
Basically I need the following structure:
Category List ->
SubCategory List (with a lookup to Category) ->
Value (with a lookup to SubCategory).
But, if there is no SubCategory, use a lookup to Category. One or the other must be used, not both.
Using either a list Event Receiver (SPItemEventReceiver) or a Custom Workflow should be able to achieve these desired semantics.
I do not believe the model itself can represent such relationships. An alternative might be to have different content types, for which only one of the columns applies (to each).
Happy coding.

Resources