Filtering unique cck fields in views? - drupal

I'm trying to achieve a sort of special sorting in Drupal. Let's say we've got a table of data such as this:
Name Age Sex
John 19 Male
Mia 20 Female
Mia 21 Female
Here's what i want to acheive. I want to be able to remove one of the Mia's by filtering. The thing here is that the name field is not the node title - but a node reference. How can i select those nodereferences distinct?
Cheers!

This is possible, I think.
First install Views version 3.0-alpha2 (or later). Views 2.x will not work.
Make a view, in "advanced settings" set grouping to "yes".
Your objective will be to group by the Name of the individual. Also you can add a function like MIN or MAX to select the person with the Maximum or Minimum age. So according to example above, Mia 20 will be eliminated if we take the function to be MAX.

Related

Invisible graphs cause report to slow

I have a report with a parameter where the end user chooses a practice name that corresponds to a group of people. Most of these groups have fewer than 10 people, but a small number of them have as many as 150. When there are more than 15 people in a given group, they want separate graphs, each with no more than 15 people. So for most of the groups, we only need one graph. For a few, we need a lot of graphs.
Behind the scenes, I created a graph for each multiple of 15 people, and set them to only be visible if there are actually that many people in the group. This does what I need it to, but it makes the report super slow. As close as I can tell, behind the scenes when an end user runs the report it's still somehow rendering the hidden graphs and slowing it all to heck. (I did find this link which I think suggests this is a known bug.
I need to have one report where the end user selects the practice name, so I can't make two reports, "My practice is normal" and "My practice is ginormous". I thought maybe I could make a conditional sub-report split into those two reports based on the practice name parameter, but that doesn't appear to be possible; you can play around with visibility but I'm guessing that will still cause the invisible graph rendering problem and not help my speed.
Are there any other cool tips I can try to speed up my report, or is this just a case of too many graphs spoiling the broth?
The easiest way would be to generate a group number for every 15 people and then use a list control to repeat the chart for each group.
Here's a very quick example of this in action. I just used some sample data from one of the Adventure Works sample database.
Here's my query that returns every person in each selected department. Note that I have commented out the DELCAREs as these were just in there for testing.
--DECLARE #Department varchar(50) = ''
--DECLARE #chartMax int = 5
SELECT
GroupName, v.Department, v.FirstName, v.LastName
, ChartGroup = (ROW_NUMBER() OVER(PARTITION BY Department ORDER BY LastName, FirstName)-1) / #chartMax -- calc which chart number the person belongs to
, Salary = ((ABS(CHECKSUM(NewId())) % 100) * 500) + (ABS(CHECKSUM(NewId())) % 1000) + 10000 -- Just some random number to plot
FROM [HumanResources].[vEmployeeDepartment] v
WHERE Department IN (#Department)
ORDER BY Department
The key bit is the ChartGroup column
ChartGroup = (ROW_NUMBER() OVER(PARTITION BY Department ORDER BY LastName, FirstName)-1) / #chartMax
This will give the first 5 rows in each department a ChartGroup of 0 the next 15 1 and so on. I used 5 rather than 15 just so it's easier to demo.
Here's the dataset results
Now, in your report, add a List, set it's dataset property to your dataset containing your main data (the query above in my case).
Now edit the 'details' rowgroup properties and add a grouping by Practice and ChartGroup (Department and ChartGroup in this example)
In the list box's textbox, right-click then insert a chart.
Set the chart up as required, in my example, I used salary as the values on a pie chart and the employee names as the labels.
Here's the final design ..
Note that I set the department as a multi-value parameter and also set the number of persons per chart (chartMax) as a report parameter.
When I preview the report I get this for 'Engineering' which has 6 employees
Sales has 18 employees so we get this
.... and so on, it will generate a new chart for every 15 people or part thereof.

Netsuite - Saved Search - String All True Results of Case Formula

Hoping someone can help me out with a NetSuite question, and I apologize in advance if i’m misusing some lingo.
I am creating a item based saved search and one of my formula (text) result fields can have multiple true values when I apply my case formula. I’m look to combine all the true results of this formula into one comma separated string, instead of a new item row for each true value.
sku contact type
123 John S Owner
123 Jane S Clerk
123 Jack S Clerk
Formula (text) - Custom Label Field Name = Contact Name
Case when {type} = ‘Clerk’ then {contact} end
Currently my results generate a item (sku) row for each case of clerk:
Sku Contact Name
123 Jane S
123 Jack S
I’m looking for my results to be a single string
Sku Contact Name
123 Jane S, Jack S
I know the case function noted above will not string the results by itself; I originally intended to use the group by and max summary types, but I only get one Contact Name result.
Any solutions or work arounds?
Thanks
There are certain grouping functionality available for saved search results, but I don't think what you are trying to do is possible.
If you group your results by Sku, you will get one line per Sku but concenating the contact names from different line results I don't think is possible.
In your SaveSearch's Filter look for mainline and try to set either true(Yes) Or false(No).
There is an undocumented Netsuite function NS_CONCAT() (similar to Oracle's undocumented WM_CONCAT()) that does exactly this. You would group your results by the SKU column, and add formula field with the formula NS_CONCAT({contact}) and the summary type set to Minimum or Maximum.
According to some Netsuite employees on the Netsuite User Group, the LISTAGG function should also work now, and offers more flexibility (if you wanted a delimiter other than a comma for example).

Enter data in mother table using data from child tables

Hi all,
I have 3 tables in an access 2010 database:
Crew: CrewID; Name; Adres;...
Voyage: VoyageId; Voyage name; Departure harbour; Arrival harbour
Crewlist: CrewlistId, VoaygeId, CrewId, Rank
The VoaygeId and CrewId from the Crewlist table are linked (relation) to the autonumber ID's from tables 2 and 1.
My first and main question is: Upon boarding everyone has to ‘sign in’ selecting the voyage and there name, and assign them a roll (of to be donde by the responsible officer). How can I make a form that lets the users browse through the voyagenames and crewnames in stead of the ID’s uses in the ‘mother’ table (table 3: Crewlist)
2nd question: how can I make sure that someone isn’t enrolled twice for the same voyage (adding same voyagenumber and same crewId number in crewlist). This would preferably be blocked upon trying to add the same person a second time on a voyage.
To prevent duplicates in Crewlist, add a unique index to the table on both CrewId and VoyageId
It would be a good idea to add relationships and enforce referential integrity
You are now in a position to use the wizards to create a form based on Voyage and a subform based on CrewList with a combobox based on Crew
There are a number of refinements you could add.
Make sure you do not use reserved words like Name and do not put spaces in field names. You will thank yourself later.
See also create form to add records in multiple tables

Repeater with dynamic number of columns

Repeater with dynamic columns.
I have to show columns based of settings. Sometimes I want to show Name, Age, Sex, Salary. So the stored procedure will return
Name Age Sex Salary
-----------------------
Rauf 23 M 10
Amal 25 M 10
Sometimes I need to show Name and Salary only. So the data will be
Name Salary
------------
Rauf 10
Amal 10
How can I design a Repeater control to show this type of tables having dynamic columns ?
Unless perfomance i really crucial, I would take the easy way and use fixed columns (all of them) and just set visible=false in case you do not need them.

Edit and create nodes in a view?

We are storing people's class attendance information to Drupal. We would like to show this in a grid/chart, where the first column of each row shows person's name, and rest of the columns (ca. 20) either a checkbox or "X" if the user attended a class, or otherwise an non-checked box or empty column:
(dates here)
Jack X XXX X X
Jill XX XXX XX
It should also be possible to edit the attendance information on the grid. Each attendance information is a node of its own.
This functionality can probably mostly be achieved using views and editablefields, but there is one problem: if a person has not attended a specific class he/she will not have at all an attendace node for that day. What would be the easiest way to create an attendace node in those cases, so that it would be possible for the end user to edit the grid by just clicking on the checkbox or typing an 'X'?
You could use the Rules module to automatically create the nodes.
I'm not quite sure about the functionality you want to achieve, but it sounds like a doodle like one. So you may want to check out the http://drupal.org/project/date_picker_formatter module (successor of http://drupal.org/project/dudel).

Resources