DataTables yadcf Multi select filter Server Side Script - datatables

I am using DataTables with Server Side and yadcf Multi select filter.
I have a database that I need to filter by multiple Caja ID, on the Database the Caja ID is just a number (1-30) i already did the yadcf_data_14 for the label and value of the filter.
The filter works almost good when i select 1 filter. If i Select Caja ID = 1 then i shows me all the items that has 1 and also 10 to 19 and 21. I am guessing it is a contains filter not exact value.
Also, when i select the second item to filter, then I shows Nothing.
I need help on getting the filter working when i select 1 to show me exactly the value selected, and when i select 2 filters then show me all the results of the 2 selected values.
Image with 1 Filter:
Image with 2 Filter

Related

Limit number of script triggers by field

I am trying to figure out how to limit the number of times an ID can be selected.
I have a list of mentors, some who can be selected 1 time and others who can be selected 2 times. I am using a button that performs a Set Field script. When the button is clicked the ID value is copied to another list. It remains in the original list but also is shown in another. I want to say something like:
If field "mentor count" = 2 then You can select 2 times, else you can select 1 time.
I have no idea how to go about it.
Do you have any suggestions please?
There are a total of 3 lists. One is mentors, 1 is students and the other is both. The user selects a mentor and student to match up. Each row in this table is a new match.
I tried conditional action which failed. I am thinking I will need a script.

Ignore a column in MS ACCESS query if the WHERE clause is not set

Problem
I've got a dropdown list, which shows all the Article_Group_ID's that are linked to a specific brand, using the following Query:
SELECT TbArticle.Article_Group_ID, TbArticle.Article_Brand_ID
FROM TbArticle
GROUP BY TbArticle.Article_Group_ID, TbArticle.Article_Brand_ID,
HAVING (((TbArticle.Article_Brand_ID)=1))
This works as expected, it returns the following:
Query results
Article_Brand_ID
Article_Group_ID
1
1
1
2
But, if a user does not wish to specify a specific Article_Brand_ID, the query results look like this:
Query
Article_Brand_ID
Article_Group_ID
1
1
2
1
3
1
1
2
As you can see, the same Article_Group_ID is returned three times. Because of this, the user now sees the same group three times, instead of just once. If I were to remove the Article_Brand_ID from the query, the results would look like this:
Article_Group_ID
1
2
Is there any way to achieve the same behavior, by "ignoring" the Article_Brand_ID column, if it's WHERE clause is not set?
Database layout
TbArticle
Article_Brand_ID
Article_Group_ID
1
1
2
1
3
1
1
2
A single query cannot return a variable number of columns. So, strictly speaking you cannot do what you want with a single query. However, if you are willing to accept the second column as NULL when the brand is not provided, then you can adjust the aggregation.
Let me denote the parameter by ?:
SELECT a.Article_Group_ID,
IIF(? IS NOT NULL, a.Article_Brand_ID, NULL) as Article_Brand_ID
FROM TbArticle as a
WHERE a.Article_Brand_ID = ? OR
? IS NULL
GROUP BY a.Article_Group_ID,
IIF(? IS NOT NULL, a.Article_Brand_ID, NULL);
Note: It is usually better to filter before aggregating (i.e. using WHERE) rather than filtering afterwards (i.e. using HAVING).

Choosing which rows to sum and average in either SSRS or SQL

ROW column 1 column 2
1 A 1
2 A 1
3 A 3
4 A 1
5 A 2
6 B 1
7 B 3
8 B 1
Pic of table
Lets say I have this table as shown above. I want to be able to average SELECTED values from column 2. Am I able to use any function in SSRS that allows me to select which value to use to average? The end goal is to allow the user to interactively choose which value to average.
For example if I would want to use ("Row 1 + Row 2 + Row 4")/3, or (Row 6 + Row 8)/2, how can I go about letting the end user to choose those values to average?
Is there something that I need to do in SQL first to make it easier in SSRS?
The idea is by using report parameter and dataset filter
Add parameter in SSRS to allow user input of multiple values, set the available values for row-1, row-2, and so on
here for your reference how to add the parameter in SSRS
https://learn.microsoft.com/en-us/sql/reporting-services/report-design/add-change-or-delete-a-report-parameter-report-builder-and-ssrs?view=sql-server-ver15#:~:text=To%20add%20or%20edit%20a,or%20accept%20the%20default%20name.
after you add the parameter, let's say you already have a dataset which is SQL query such as:
SELECT *
FROM the_table
Right click on your dataset, on properties, in the filter tab, add a filter for the column ROW IN parameter that you have made earlier
after you add filter on your dataset, on your report, simply use that dataset and put expression AVG(Column 2)

SSRS displaying columns on a matrix to the right

I have a table that looks like so:
Is there any way I can display it like this in SSRS?
1 2 3 4
1 2.091 0.918 0.9 1.718
2 0.647 0.964 0.6 2.264
3 0.804 0.789 0.6 1.9
I tried using a matrix but it stops after showing the first column and doesn't expand to show the rest.
Attempt:
Results:
Another attempt:
Results:
to get something similar to the result you're looking for you need to write a query like:
select id
,row_number() over(partition by SubscaleNumber order by SubscaleNumber ) SubscaleNumber
, item
from yourtable
then the matrix should work fine.
You need to set the Row and Column grouping to get this matrix-style output.
When you click in your table you should see the brackets for the Row and Column groups. If you don't have a column group, add one.
Go into the properties of each group and make sure they are grouped by the column you want.
Start from scratch with a table or matrix.
Add a Row group on id
Add a Column Group on Item.

How to restrict displaytag to make database call on sorting?

I have a list of 1000 records, and I shown there 1000 records on page load using display tag.
I enabled sorting on some columns, and when I click on the table header to sort, display tag is making a database call and loading all 1000 records again.
How can we restrict to make database calls on sorting for display tag?
Because, we have loaded all the 1000 records, so could we make use of those list without loading the records again?
You are missing a fundamental: Pagination.
You should not load 1000 records at once; load 10 records at once instead (assuming 10 records is what you show in a page), and load the other 10 when changing page / sorting.
Filter them directly in the query (if you are using queries), for example, selecting page 3 (results from 21 to 30) in a query to a minimal "person table", ordered by name, would result it the following SQL:
Oracle
SELECT id, name, age
FROM ( SELECT id, name, age
FROM table_person
ORDER BY name )
WHERE ROWNUM BETWEEN 21 and 30
PostgreSQL
SELECT id, name, age
FROM table_person
ORDER BY name
LIMIT 10
OFFSET 20
and so on.
Be sure to read the documentation related to your database, and simply use query parameters to specify order by, starting row and ending row values.
you can use setFirstResults(), setMaxResults(),instead unnecessarily load all 1000 records.
divde per page max result shown 10 records only, and setFirstResult is restricted records first 5 from your records list.
Criteria cr= database_session.createCriteria(Records.class);
cr.addOrder(Order.desc("Recordsdate"));
cr.setFirstResult(5);
cr.setMaxResults(10);
all_records_list = (List<Records>) cr.list();