Change Group Labels in AdvancedDataGrid - flex4

I'm trying to use an AdvancedDataGrid to display some grouped data. Normally flex displays this in a "tree view" with a folder icon represent the group. I need to group the data based on an integer ID field in my object, but I'd like the label for the folder icon to display the groupName field in my object.
Here's a little example:
{groupName: group1, ID: 1234}
{groupName: group2, ID: 5678}
<mx:grouping>
<mx:Grouping label="Group"> <--- The label of the whole column
<mx:GroupingField name="ID">
</mx:Grouping>
</mx:grouping>
Resulting output:
=== Group ===
+ 1234
- child
- child
+ 5678
...
But I'd really like to output:
=== Group ===
+ group1
- child
- child
+ group2
...
If anyone has any tips I'd appreciate it.
-- Dan

Have a look at GroupingField#groupingFunction. From the adobe docs:
A function that determines the label for this group. By default, the group displays the text for the field in the data that matches the filed specified by the name property. However, sometimes you want to group the items based on more than one field in the data, or group based on something that is not a simple String field. In such a case, you specify a callback function by using the groupingFunction property.
private function myGroupingFunction(value:Object, field:GroupingField):String

Related

How to Select multiple related columns in add calculated fields in Quicksight parameter using ifelse?

I have a parameter 'type' in a table and it can have multiple values as follows -
human
chimpanzee
orangutan
I have 3 columns related to each type in the table -
human_avg_height, human_avg_weight, human_avg_lifespan
chimpanzee_avg_height, chimpanzee_avg_weight, chimpanzee_avg_lifespan
orangutan_avg_height, orangutan_avg_weight, orangutan_avg_lifespan
So if i select the type as human, the quicksight dashboard should only display the three columns -
human_avg_height, human_avg_weight, human_avg_lifespan
and should not display the following columns -
chimpanzee_avg_height, chimpanzee_avg_weight, chimpanzee_avg_lifespan
orangutan_avg_height, orangutan_avg_weight, orangutan_avg_lifespan
I created the parameter type and in the add calculated fields I am trying to use ifelse to select the columns based on the parameter selected as follows -
ifelse(${type}='human',{human_avg_height}, {human_avg_weight}, {human_avg_lifespan},{function})
I also tried -
ifelse(${type}='human',{{human_avg_height}, {human_avg_weight}, {human_avg_lifespan},{function}})
And -
ifelse(${type}='human',{human_avg_height, human_avg_weight, human_avg_lifespan},{function}})
But none of it is working. What am i doing wrong ?
One way to do this would be to use three different calculated fields, one for all the heights, one for weights and one for lifespan. The heights one would look like this:
ifelse(
${type}='human',{human_avg_height}, ifelse(
${type}='chimpanzee', { chimpanzee_avg_height}, ifelse(
${type}='orangutan',{ orangutan_avg_height},
NULL
)))
Make another calculated field for weights and lifespan and then add these calculated fields to your table, and filter by type.
To make it clear to the viewer what data is present, edit the Title of the visual to include the type:
${type} Data
You have to create one calculated field for each measure using the ifelse with the type to choose the correct vale, but is not necessary to create inner ifelse as skabo did, the if else syntax is ifelse(if, then [, if, then ...], else) so you can define the calculated fields as follows:
avg_height = ifelse(${type}='human', {human_avg_height}, ${type}='chimpanzee', {chimpanzee_avg_height},${type}='orangutan', {orangutan_avg_height}, NULL)
avg_weight = ifelse(${type}='human', {human_avg_weight}, ${type}='chimpanzee', {chimpanzee_avg_weight},${type}='orangutan', {orangutan_avg_weight}, NULL)
avg_lifespan = ifelse(${type}='human', {human_avg_lifespan}, ${type}='chimpanzee', {chimpanzee_avg_lifespan},${type}='orangutan', {orangutan_avg_lifespan}, NULL)
Then use those calculated fields in your visuals.

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

Show Different category name in tooltip in spotfire bar chart

We have a requirement for showing ID in category axis and description of same ID in tooltip.
I have multiple columns in my data like value 1 ,value2,value 3 etc. value 1, value 2 are columns.
I am putting this on value axis as an expression like Sum([value 1]) as [AC 6076 ], Sum([Value 2]) as [AC 6078 ], etc. that is this will hardcoded as IDs in category axis
So my category axis is column names. that is <[Axis.Default.Names]> .
please see the attached picture. It's the description against a column not a row.
It would be an expression in tooltip which may be something like
First(Case when '${Axis.Y.DisplayName}'='AC 6076' then "description 1" when '${Axis.Y.DisplayName}'='AC 6078 ' then "description 2" else " Description 3" end )
This expression is not showing correct value. it wil always show "Descrition 3"
i want to show this IDs(column names in category axis) and a description for each of these column names in tooltip. please have a look at the picture attached.
Atatched picture
Thanks
First(CASE
WHEN '${Axis.Y.DisplayName}'='AC 6076' THEN "description 1"
WHEN '${Axis.Y.DisplayName}'='AC 6078 ' THEN "description 2"
ELSE " Description 3"
END)
this always evaluates to your ELSE condition because ${Axis.Y.DisplayName} will always be the full display name for the axis, not the individual columns (i.e., "AC 6076, AC 6078").
you will need to add your description text to your data somehow. this is a little convoluted and will require some tweaking on your end, but the principle is the same.
this is assuming your table is something like this:
key val1 val2
a 1 4
b 2 5
c 3 6
from the menu, select File..Add Data Tables...
click Add then select the data table powering your visualization from the From Current Analysis heading
expand the Transformations pane at the bottom of this dialog
choose a Pivot transform and click **Add...*
leave everything default except for Transfer columns..., where you should add only the columns you wish to sum (e.g., [value 1] and [value 2])
OPTIONALLY change the naming scheme to just %T
click OK
your table now looks like (ignoring optional steps):
Sum(val1) Sum(val2)
6 15
choose another transform, this time Unpivot, and click **Add...*
add all columns to Columns to transform
click OK
now you have:
Category Value
Sum(val1) 6
Sum(val2) 15
choose one last transform: Calculate new column and click **Add...*
enter your case statement that will determine the description and name the column "Description" or something
click OK
click OK
your final table will resemble:
Category Value Description
Sum(val1) 6 This is the sum of value 1
Sum(val2) 15 This is the sum of value 2
on your bar chart, the category axis expression should be Category and value should be Sum(Value) (assuming you didn't change the column names in step 9)
add a new line to the tooltip with an expression First([Description]), or whatever you named the new column in step 12
whew. it's a lot of steps but it works. the goal is to get the description data into it's own column so you can put it in the tooltip. since your data is aggregated and doesn't exist in its own column, this is the only way I can think of doing it.

Counting a field value response weekly basis in Lotus Notes

I have radio button field in a form whose value can be 1 or 2 or 3. I have a made a view out of this form and there one column will contain the value of this radio button field . Whenever a customer submits the form, a new document will appear in the view. A customer can submit the form many times with different value of this radio button. Is it possible to know how many times a particular customer selected the value 1?
Yes, you can create a view where the first column is your customer name and the second column is their response. Both columns should be "categorized" meaning they'll group the like values.
For each column you can set the formula to include the number of documents within the group. For example:
CustomerName + " (" + #DocChildren + ")"
will show you "ABC Company (12)" if ABC had 12 responses.

Pig: Aggregate with specific parameter dynamically

I have data some data that I want to plot, but the aggregation parameter is dependent on the user. The data looks like this-
Date Country Browser Count
---- ------- ------- -----
2015-07-11,US,Chrome,18
2015-07-11,US,Opera Mini,10
2015-07-11,US,Firefox,21
2015-07-11,US,IE,11
2015-07-11,US,Safari,8
...
2015-07-11,UK,Chrome,102
2015-07-11,UK,IE,45
2015-07-11,UK,Mobile Safari,47
2015-07-11,UK,Firefox,40
...
2015-07-11,DE,Android browser,50
2015-07-11,DE,Chrome,3
2015-07-11,DE,IE,11
2015-07-11,DE,Firefox,20
The user will tell me what to aggregate by (country or browser), and I want to display the counts. For example, grouped by country (aggregated by browser) it would be -
2015-07-11,US,ALL,68
2015-07-11,UK,ALL,234
2015-07-11,DE,ALL,84
whereas grouped by browser (aggregated by country) might be -
2015-07-11,ALL,IE,67
2015-07-11,ALL,Chrome,123
2015-07-11,ALL,Firefox,81
Would I have to write separate scripts based on each column or are there more efficient ways of doing this?
Better to write a macro to which the the alias name and the field name : 'country', 'browser' is passed. Aggregation logic remains the same.
Ref : http://pig.apache.org/docs/r0.10.0/cont.html#macros
Example :
Pig script :
DEFINE AGGR_DATA(alias, field_name) RETURN aggr_alias {
alias_grp = GROUP $alias BY $field_name;
-- REST OF LOGIC
$aggr_alias = -- AGGR DATA;
}
Usage :
aggr_data = AGGR_DATA(browser_data_alias,'country');
Pass the required field name to macro.

Resources