Creating dynamic data validation - google-sheets-formula

Given the following dataset in one sheet, let's say 'Product Types' (columns and headers displayed):
| A | B | C |
| :----------: | :------: | :-----: |
| Product Type | Desktops | Laptops |
| Desktops | Dell | Dell |
| Laptops | HP | Apple |
In another sheet, let's say 'Assets', I've set column A to require a match to the data validation of an item listed in column A of 'Product Types' (not including the header). What I'm trying to do is that once column A is selected in 'Assets', I'd like to create a dynamic query data validation that will then present the values of the column with the header in 'Product Types'.
As an example, in the 'Assets' sheet, if column A has "Laptops" selected, column B will use data validation for values under the "Laptops" column in 'Product Types'; then giving the only options as "Dell" or "Apple". Alternatively, if ColA is changed to "Desktops", data validation is defined to only allow "Dell" or "HP" as options.
I'm unsure if this is possible. However, data validation in Google Sheets claims to allow a range or "formula".
I don't remember where I sourced this formula from, but it can present the values I need when running the query within a cell. However, I'm unable to use the same formula within a data validation field.
=ARRAYFORMULA(IFERROR(VLOOKUP(A2, TRANSPOSE({'Product Types'!A1:M1;
REGEXREPLACE(TRIM(QUERY(IF('Product Types'!A2:M<>"", 'Product Types'!A2:M&",", )
,,999^99)), ",$", )}), 2, 0)))
The above query presents the correct comma-separated values of the column I want in 'Product Types', but I'm not sure if this can be translated into something data validation can use or if there's altogether a different method to accomplish this.
P.S. I'm new. Markdown for the table seems to work when editing, but not when published..

the answer is no. data validation does not support direct input of complex formulae. you will need to run your formula in some column and then reference the range of that column within the data validation

Related

Using header names as a filter parameter in a dashboard

I have a data table that resembles the structure here:
| Prof | PI | Class |
|:----:|:------:|:-----:|
| Dr.K | Louisa | A |
| Dr.L | Jenny | B |
| Dr.X | Liu | C |
Filter 1: I'd like to create two dropdown, single selection parameter-filters, the first of which contains the headers of the columns. So, filter one would contain the option to select: Pro, PI, or Class.
Filter 2: The second filter would then dynamically change to represent values of the selected column. If a user chose "Prof" in Filter 1, Filter 2 would show: Dr. K, Dr. L, and Dr. X. The table in the dashboard would then reflect the chosen filters.
I believe choosing "only relevant values" on Filter 2 would take care of some of the issues, but I still don't understand how I can turn column headers into a list, and those values still retain the integrity of the original columns. Thank you for any help you can provide!
IF [Parameter 1] = STR("Prof") THEN [Prof] ELSEIF [Parameter 1] STR("PI") THEN [PI] END

ag-grid modify Row Group's Header name

I'm using ag-grid to display a table which has a Row Grouping.
The column that I group by is invisible since its value holds no meaning.
So for example, I will have the following (fully collapsed) table:
---------------------------------
| H1 H2 H3 |
----------------------------------
| > groupId1 (1) |
----------------------------------
| > groupId2 (5) |
----------------------------------
As you see the grouping is done by user-unfriendly ID which is not reflected at all in the Column Definitions. I would like to change groupId1 / groupId2 to a user-friendly text that is assigned dynamically according to the content of the group rows.
I am using React.
I am using ag-Grids examples as a starting point, the following example embodies the problem I'm facing: (eg: https://plnkr.co/edit/VM59gScPD55PhX4y4JBj?p=preview)
It has row grouping
The grouping is done by a column that is invisible (country)
I would like to change the country name dynamically into a different value that's derived from the values of the inner row.
Thanks for your time. :)
You can also rename the rowGroup header of ag-grid by using this simple prop
autoGroupColumnDef
<AgGridReact
columnDefs={columnDefs}
rowData={rowData}
autoGroupColumnDef={{
headerName: 'Name'
}}
/>
A colleague helped me at the end, his solution was:
valueFormatter: ({ value, data }) => 'something ' + value
inside the colDef of my group, and the value to be displayed as the header is sent inside 'data'.
He said that cellRenderer is an overkill for a simple task like this.
You can pass additional params about group cell renderer and customize it like this -
colDef = {
// set the cell renderer to 'group'
cellRenderer:'agGroupCellRenderer',
// provide extra params to the cellRenderer
cellRendererParams: {
innerRenderer: myInnerRenderer, // provide an inner renderer
}
...
};
You should be then able to display any text based on custom logic using the myInnerRenderer implementation.
Here is an example from ag-grid docs. Check the Group Renderer C implementation

How to bind values from CSV files with a query to database?

I'm trying to build a report using BIRT. I define several data sources: two CSV-files and MySQL database. A query that receives data from the database looks like this:
SELECT applicationType, STATUS, COUNT(*)
FROM cards
GROUP BY applicationType, STATUS;
Then I created a table with three columns that outputs these values from the query:
So far so good. But I want to output values from CSV-files instead of applicationType and status. The first file, apptype.csv, has the following structure:
applicationType,apptypedescr
1,"Common Type"
2,"Type 1"
...
and the second one, statuscards.csv, has the following structure:
status,statuscards
1,"Blocked"
2,"Normal"
...
And instead of:
Тип приложения | Статус карты | Количество
---------------|--------------|------------
1 | 2 | 55
I want to output the following:
Тип приложения | Статус карты | Количество
---------------|----------------|------------
Common Type | Normal | 55
I alse created New Joint Data Set to bind MySQL dataset and the first file dataset:
But I don't know how to change the table now. As far as I understand, [applicationType] in the first column should be replaced with [apptypedescr]:
but I'm not able to drag this field into the table, it's possible to add it to the report only outside the table. How can I bind these values from the CSV files to data from the MySQL query in the table?
I did this by setting new dataset for table in Properties -> Binding -> DataSet. After this the report was built properly:

Spotfire: Using one selection as a range for another datatable

I've searched quite a bit for this and can't find a good solution anywhere to what seems to me like a normal problem for this product.
I've got a data table (in memory) that is from a rollup table(call it 'Ranges'). Basically like so:
id | name | f1 | f2 | totals
0 | Channel1 | 450 | 680 | 51
1 | Channel2 | 890 | 990 | 220
...and so on
Which creates a bar chart with Name on the X and Totals on the Y.
I have another table that is an external link to a large (500M+ rows) table. That table (call it 'Actuals') has a column ('Fc') that can fit inside the F1 and F2 values of Ranges.
I need a way for Spotfire Analyst (v7.x) to use the selection of the the bar chart for Ranges to trigger this select statement:
SELECT * FROM Actuals WHERE Actuals.Fc between [Ranges].[F1] AND [Ranges].[F2]
But there aren't any relationships (Foreign keys) between the two data sources, one is in memory (Ranges) and the other is dynamic loaded.
TLDR: How do I use the selected rows from one visualization as a filter expression for another visualization's data?
My choice for the workaround:
Add a button which says 'Load Selected Data'
This will run the following code, which will store the values of F1 and F2 in a Document Property, which you can then use to filter your Dynamically Loaded table and trigger a refresh (either with the refresh code or by setting it to load automatically).
rowIndexSet=Document.ActiveMarkingSelectionReference.GetSelection(Document.Data.Tables["IL_Ranges"]).AsIndexSet()
if rowIndexSet.IsEmpty != True:
Document.Properties["udF1"] = Document.Data.Tables["IL_Ranges"].Columns["F1"].RowValues.GetFormattedValue(rowIndexSet.First)
Document.Properties["udF2"] = Document.Data.Tables["IL_Ranges"].Columns["F2"].RowValues.GetFormattedValue(rowIndexSet.First)
if Document.Data.Tables.Contains("IL_Actuals")==True:
myTable=Document.Data.Tables["IL_Actuals"]
if myTable.IsRefreshable and myTable.NeedsRefresh:
myTable.Refresh()
This is currently operating on the assumption that you will not allow your user to view multiple ranges at a time, and simply shows the first one selected.
If you DO want to allow them to view multiple ranges, you can run a cursor through your IL_Ranges table to either get the Min and Max for each value, and limit the Actuals between the min and max, or you can create a string that will essentially say 'Fc between 450 and 680 or Fc between 890 and 990', pass that through to a stored procedure as a string, which will execute the quasi-dynamic statement, and grab the resulting dataset.

Populating Birt through columns

I have been trying to come up with a birt report to print food tag to no avail. What i want to show on the report is:
foodtag1 | foodtag2 | foodtag3
foodtag4 | foodtag5 | foodtag6
foodtag7 | foodtag8 | foodtag9
Can this be done?
the data is taken from a MySql Query "select dishes.name
from dishes
where find_in_set (dishes.id,(select orders.dishes from orders where orders.id = ))"
** Note: FoodTags 1-9 are all unique name of dishes
** Also note that foodtag 1-9 are representatives of a dish name. FoodTag1 can be "Yang Zhou Fried Rice", it can be "italian Pasta". it can be "Mee Goreng". Data is taken out from a datasource in MYSQL server
The easiest way--
Drag a grid element to your report, set it at 3 columns and 3 rows
In property editor, bind the grid to the data set
Drag a dynamic text element to the first cell in the grid
Then use JavaScript simular to this to filter to the desired text.
if (row["FoodTagColumn"]=='foodtag1'){
row["FoodTagColumn"]
}else null

Resources