Limit number of rows displayed per group in ag-grid - ag-grid

Is there a way to filter top n rows per group in ag-grid-react? For example, I have applied sort on the price column and I want to see 5 highest-priced rows per group, is it possible to do this using some api or event handler?

Related

Select top x% records

Question is regarding how to get top x% of records according to their ratings.
For example I have a table with a few columns, one of which is rating:
rating smallint
value of rating is always positive.
My goal is to select top x% of entries according to their rating.
For example, for top 20%, if set of selected rows contains ratings like:
1,3,4,4,5,2,7,10,9
Then top 20% would be records with range from 8 to 10 → records with rating 9 and 10.
I implemented it in Django but it takes 2 calls to DB and I believe it can be easily achieved via SQL in PostgreSQL by just one call.
Any ideas how to implement it?
Considering that the max rating available in the column is your base for max calculation.
Try this workaround:
select * from sample where rating >=(select max(rating)-max(rating)*20/100 from sample)
Demo on fiddle

Tableau - Related Data Source Filter

I have data split between two different tables, at different levels of detail. The first table has transaction data that, in the fomrat:
category item spend
a 1 10
a 2 5
a 3 10
b 1 15
b 2 10
The second table is a budget by category in the format
category limit
a 40
b 30
I want to show three BANs, Total Spend, Total Limit, and Total Limit - Spend, and be able to filter by category across the related data source (transaction is related to budget table by category). However, I can't seem to get the filter / relationship right. That is, if I use category as a filter from the transaction table and set it to filter all using related data source, it doesn't filter the Total Limit amount. Using 2018.1, fyi.
Although you have data split across 2 tables they can be joined using the category field and available as a single data source. You would be then be able to use category as a quick filter.

How do I filter by more than one measure

I have a Word Cloud visual. The size of my words are determined by my total number of employees. Employees is its own field. Two other fields are FTE and Contract and they add up to my total employees. I want to filter my visual by either FTE or Contract. But when I drag these Measures under Filters and uncheck one, it results in no data displaying.
From your excel snapshot, it looks like you have a column for FTE and Contract. Since all records have a value for each column, if you "uncheck" one of them. All record will be filtered out.
From your question it appears you are trying to size the words based upon the number in either FTE or Contract (not total employees)? If this is the case, I would recommend creating a separate calculated field that toggles between the two fields based on a parameter value.
Ex. Calculated Field 1
IF [parameter] = "FTE"
THEN [FTE]
ELSEIF [parameter] = "Contract"
THEN [Contract]
ELSEIF [parameter] = "Total Employees'
THEN [Total Employees]
END
Ex. Parameter (String), List
Value Display As
FTE FTE
Contract Contract
Total Employees Total Employees

Referencing first record in a group in crystal reports

In my report, in group footer, I want to add the sum on a column from all records in the group except the first one. How can I do that?
I tried Insert - Subtotal but it adds all records. If I can access the first record from each group, I can subtract it from the sum.
Let's say you're grouping your report by {Table.GroupID} and want to get the total per group, excluding the first record in the group, for {Table.NumericField}.
You can do this by creating a running total where:
Field to summarize: Table.NumericField; Type of summary: Sum
Set to evaluate with a formula: previous({Table.GroupID})={Table.GroupID}
Reset on change of group
The second step ensures that the group total is updated for every record except the first one in the group and can be read as "Only evaluate this running total when the previous record's GroupID is the same as the current record's GroupID.

SSRS 2008 Charts: Selective Filtering on Charts within a chart

I have 3 Chart Series A,B,C of Data on single Chart
Normally When I apply filter on single series,the filter takes affect on all 3 series A,B,C .What I need is someway to apply particular filter on Series A,B but not C
like i have billable status as billable, non billable and partial billable.
i want two columns in the chart. 1 depicting only non billable employees and 1 showing the total of all billable status i.e., the whole team size.
my category axis has month.
i am not able to apply selective filters for one column of the two that i require.
please help.
You wont be able to do what you want, because each series/category is a subset of your dataset, meaning that if you group by "all" then all elements of your data set will fall into that category.
The best way to achieve what you want is on the query that creates the dataset do a Union with the total of employees, something like:
SELECT 1 as NumberEmployees, SSN, BillableStatus FROM mytable
UNION
SELECT COUNT(*), 0 as SSN, -1 as BillableStatus FROM mytable
Then when you'll have a status -1 that corresponds to all employees, and will appear on the chart as a different bar