custom vaadin-grid filter for Polymer 1.0 - vaadin

I’m using the vaadin-grid#^3.0.2 in my polymer 1.0 project.
But I’m looking to create an on/off toggle button that will filter a column based on if the text in two columns are not a match. So if a row in column 1 contains text=“1.1.1” and that same row in column 2 contains text = “2.1.1" then I would keep this row displayed, and hide all other rows. I want to do this in javscript. I’m very new to the vaadin-grid (had so much previous experience with iron-data-table). Anyone have a suggestion on how I can access the filter function?
image of 2 different columns of versions
I tried using the standard filter element but it's too limiting because it only allows me to do string based filtering on just one-specific column, but it's not built so I can do a comparison between strings in two different columns.
<vaadin-grid-filter path="version" value="[[_filterVersion]]">
<input value="{{_filterVersion::input}}">
</vaadin-grid-filter>

One simple way to do filtering that looks at the values of two columns is to not use vaadin-grid-filter, rather just have a input field outside the grid, then filter the array bound to the grid's items property as needed.
<vaadin-textfield on-value-changed="_filterMethod"></vaadin-textfield>
_filterMethod(evt) {
this.gridItems = this.allItems.filter(it => it.col1 !== it.col2);
}
Although I may not fully understand your question as I don't why you are using an input field instead of a button. This filter method approach should work equally well if you call it from a button instead.

Related

Is it possible to apply a filter to a specific sheet based on a parameter?

I have 6+ sheets on my dashboard and I want to be able to filter/search a value, but only apply it to the sheet I selected.
Further explanation:
I have a parameter list w/ the following values: Sheet1, Sheet2, Sheet3
Based on this parameter, I have a calculated field that outputs the values from Sheet1 if Sheet1 was selected, and so on.
If parameter is Sheet1, then I want to filter/search only in Sheet1. If it's Sheet2, I want to filter/search on Sheet2 only.
Is this possible on Tableau Desktop?
I'm not able to provide a workbook, apologies in advance.
Hello datascientistwannabe,
Don't worry about the workbook, its not needed and besides, if you were to share something, always best to use Superstore.
Yes, the great thing about Tableau is that you can be really specific about how interactions affect different vizzes. You have the choice of defining filtering from the actions menu by decided which sheets shall be targeted, and for greater granularity, you can even determine which fields are affected rather than all fields.
Also, you could tie calculations to parameters so as a parameter is updated, so too is the calculation, and then you can simply use the calculation.
Or, if you really want control, how about using different data sets for your visuals, controlling them by parameter, and then using Set Parameter actions, to populate parameters using data from a different source.
Steve

Google Sheets filter() wrapped in arrayformula() without vlookup()

Reference/test sheet: https://docs.google.com/spreadsheets/d/1fp6ZTBtgb5E0J9GKOqh8Ae47OzY1smec5ha9BfUfAsY/edit?usp=sharing
I have a Google Sheets document with one sheet (calculator) that pulls some values from another sheet (database). database is organized by two columns: make, and model. I use some weird data validation and helper columns to make dropdowns in calculator. Then I use filter() to pull the matching value from database.
This all works fine but it will be a calculator that gets reused and the data discarded, so I need only a finite number of rows in calculator (10-20). For this, it would be super nice to be able to select the whole row and hit delete to clear the calculation without destroying all the formulas. Ideally, the filter() would happen inside an arrayformula() in a hidden and protected top row to allow the rows to be easily cleared.
For some reason though, I can't get that to work. vlookup() is not an option because I need to match two keys.
On another note, it would be nice to not need the helper columns B:J and the data validation unique to each row. This is workable though as I only need a few rows. In the actual version I hide and protect B:J and there are many more columns there.
I know you said Vlookup() wouldn't work because you need to match on two keys, I think that vlookup() will help in this situation. Try this formula...
=arrayformula(Vlookup(A3:A&K3:K,{database!A$2:A&database!B$2:B,database!C$2:C},2,False))
The concept here is to put those two matches you need into one unique key. So we use the curly brackets {} to build an array within the formula and combine those two lookup fields in your 'database' sheet. So the columns of A and B become concatenated into one element, and the second part of that array is the column C which you need.
To lookup then just combines your A&K columns similarly, so it can lookup that combined element. The rest of the vlookup follows as normal. I.e. we look up this concatenation against that one and when it matches it returns the second column of the array we built, in this case database!C.
I don't think I'm clear on your columns B:J, so I'm not sure if this helps you with that as well.
You can't get rid of the helper column approach, as long as you want the calculator to use drop down selection for the model. Data validation for dropdowns requires either a list of values, ie. static, so no good, or a range of cells.
What you might want to do is to put those cells in a totally separate tab, eg. DataValidation, and then hide that tab. Your Calculator sheet will then be cleaner, with no hidden columns. Column K will use for data validation the "hidden" values, formerly columns B:J, that are now built off in the DataValidation tab.

Orbeon 4.10 - Fill Repeat Repeated Grid from Checkbox

I want to fill a Repeated grid with value from a checkbox.
User would select multiple items from a checkbox then hit a button to add the required number of rows and set the value of a field in each iteration according to what was checked
I would need something like a foreach checked value : run this code
I'm having a hard time finding documentation about this kind of Xforms. I did find some info about Iterate and Iterator that seems promising but i failed to make that work.
I was able to add the required number of row to my grid but then im not sure how to use xf:setvalue set the value of each row.
Any help appreciated.
I think a combination of the iterate attribute to create a loop, the xxf:split() function to get the selected values as a sequence you can iterate on, and xf:insert to create elements will do the trick. See this example, which does the following:
And here is an example which does the same, but for a form created with Form Builder. In this case, the result is as follows:

Qlikview selection to work on multiple fields

I have three different tables that contain a similar field ('Department') meaning the possible values in each of them are exactly the same. I have a sheet that shows different objects let's say charts, line graphs, straight table etc based on table 1, 2 or 3. Now because the tables are not directly connected, I can't just have a listbox that selects works on all of them for that column. I want to have a single selection like a listbox based on one of them but a selection is made is like show me all possible values where
Field A = Field B = Field C and on deselect i want to have the same behaviour
Probably I will have to use macros but I am not finding any good guidance.
For this case you can use the set analysis p() function.
For example if your fields are named Department and Department1. Then you have have your listbox based on Department field and in the charts where is needed Department1 selection you can write expression like this:
sum( {< Department1 = p( Department ) >} Value)
This will show sum( Value ) where selected/possible values in Department are equal to Department1
As of the macros - they should be your really, really final solution and try to avoid them. They dont work on 100% when the document is published on the server and they are single threaded, which can lead to performance issues with your app.

Summing values in repeated sections in Orbeon

I have a problem when it comes to suming values from a repeated section. Specifically, when I have a repeated section in the orbeon builder with a control that has a value I can easily sum the values of these sections in a different control using sum($control-1) - in the calculated value. When inputing values in the form preview the sum is correct in my control with the summed value.
Unfortunately, when I add a section using the +Insert Below button in the form preview while testing the form the sum() function doesn't work anymore. In the control with this calculated value nothing is shown. Is there a different way to get the sum of values from repeated sections or is this a bug in orbeon?
Once you add a new section while testing the form the sum() function doesn't work anymore, because it adds a empty element to the node-set.
In XPath, when using the sum function, the value of each node is determined by trying to converting it to a number (number()), if there is a empty value, it's gonna convert to NaN, thus in the control with this calculated value nothing is shown by Orbeon.
A different way that would work would be to use the expression like: sum($control-1[text()]) . This way you are testing if the node has content before trying to sum it, so it's always gonna work.

Resources