I know that patches are sorted with the top left-most patch first and the bottom right-most patch last. My question is: if patches have an id patches-own[id] is it possible to sort patches by id. I don't want a list but an agenset?
Thanks
Alas, as noted here
https://ccl.northwestern.edu/netlogo/docs/programming.html#agentsets
agentsets are always in random order. As you likely know, however, you can make an ordered list of patches by id and then loop or map through it. The sort-on primitive will do that. As an example,
patches-own [ id ]
to test
ask patches [set id random 10000] ; assign random ids to patches
let sorted-patches sort-on [id] patches
show sorted-patches
show map [[p] -> [id] of p] sorted-patches
end
gives you a sorted list of the patch ids.
Charles
Related
Although I think this should be straightforward, I cannot seem to find the answer to this in relevant ag-grid documentation.
When I group an ag-grid, the parent nodes show the grouped values. For example, I might see a sum. This part is good.
But when I filter on this grouped grid, the filter only considers values at the leaf node level. I want to be able to filter on the aggregate parent values. How do I do this?
To be more specific, ag-grid provides a filtering example: https://www.ag-grid.com/javascript-data-grid/grouping-filtering/
The filter values are: 0, 1, 2, 3 (the leaf node medal counts). But I want to filter by countries with sum(Gold) > 10, so I want to filter on the sums (34, 11, 35...). I am surprised the sum values don't factor anywhere into the filter dropdown and was hoping to get some direction on this.
I received some details from ag-Grid, and thought I'd share them here to help someone else looking for same. Basically, this functionality does not yet exist.
It's a known limitation, and already part of the tracking pipeline under ticket AG-1228 (but unfortunately does not look to be slated for implementation soon):
Screenshot was taken from: https://www.ag-grid.com/pipeline/
My background is not in programming so I hope someone can help me with this problem, maybe there's a simple answer, I can do it manually, but I can't automate it.
This is a simplification, but I have bird sightings by region, by a person, in a sheet. I want to automate it so that each person's sightings in a region is given an order number, highest to lowest. i.e. the person with most sightings is given "1", the second highest "2", and so on.
At the moment I do the ordering by eye, but I make mistakes, and it's time-consuming
Example data (this data is in a sheet):
Region Person Sightings Order_No
Poole John 12 ?_(2)
Poole John_A 14 ?_(1)
Poole Chris 10 ?_(3)
Wareham John 5 ?_(3)
Wareham John_A 19 ?_(2)
Wareham Chris 21 ?_(1)
The values I want Google Sheets to calculate automatically are the values I've put in brackets. These are the values I input myself manually at the moment
The sheet is constantly being updated, with new rows being added, and existing being edited (so I might add a new row for a new person in Poole, or change the sightings for Poole/John from 12 to another value). If possible I want the order number to change, as I make changes to the data.
I've tried using Query, and VLookup, and Array formula, but unfortunately it's really hard for me to even get them to work at all. If someone can show me how to approach the problem, or solve it and show me the syntax, then that'll really help me.
paste in D2 cell and drag down:
=RANK(C2, FILTER(C:C, A:A=A2), 0)
_______________________________________________________
one-cell solution:
=ARRAYFORMULA(IFERROR(SORT(ROW(A2:A), SORT(ROW(A2:A), A2:A, 0, C2:C, 0), 1)-
MATCH(A2:A, SORT(A2:A, 1, 0), 0)))
i have some index(sorted set) containing key name sorted with timestamp as score, these index are for searching purpose , for example one index apple and one index red , apple contain all key name referencing an apple and red all key referencing a red thing.
All this is sorted with the timestamp of the creation of the main key, so i want to do search with that.
For one fild it's not a problem , with pagination i do zrange on apple for example to get all apple within range of pagination sorted by date, but my problem are when i want to combine 2 field.
For example if want all red apple, i can do it sure, but i must use a zunionstore and zrange(too long) or get all of the 2 index to perform a filter based on date, and i search the fastest solution to do that.
thank you for reading :)
The approach you described - ZUNIONSTORE followed by a ZRANGE is the most efficient within Redis core. Alternatively, you could use RediSearch for robuster indexing and searching abilities.
Using Tableau, I have arranged some data in a 100.00% stacked bar:
I want to sort the data descending (largest to smallest) by Valid component type (green) - is this possbile?
UPDATE (26th July 2017)
merawalaid's answer ALMOST worked; I followed the steps, adjusted the code to match my specific project, and it resulted in this:
As you can see, it is somewhat sorted, but not quite as it should be (for example, the fourth and sixth rows are featured too high in the chart.
Is there something that might be wrong that I have missed here?
I was able to do this: You can download my workbook here.
Be advised though, I feel there would probably be a simpler way out there to do this.
What I did was to create 2 calculated fields.
'ValidComponentCount': IF ([Component Type]='Valid Component') THEN 1 ELSE 0 END
'% of Valid': {FIXED [Rootname] : SUM([validCount])/COUNT([Number of Records])}
Then sorted the 'Rootname' column based on descending value of the 2nd calculated field (% of Valid).
It is hard to describe my question in the subject line. Here is an example.
I want Tableau to run query to show only Account ID that has both 2 products i selected in Product A quick filter.In this example only the second Account ID should qualify . Is this possible?
Thanks for your help in advance!
Hmm, good question. It is not possible in the way you want (at least I can't think of a way to do that), with quick filters.
I can solve your specific problem (filtering customers that have at least 2 specific products in their history), but expanding for variable n products can be really troublesome.
So first thing, create 2 parameters. Product1 and Product2. Each is a string, and you can get a list from the [Product A] field. You will use this 2 parameters to specify the 2 products you want.
Now create a calculated field, [Product flag]:
IF [Product A] = [Product1] OR [Product A] = [Product2]
THEN 1
END
Now drag [Account ID] to the filters shelf. Open the filter options and go to condition. Now select By field, [Product flag], Sum, = 2
That will work if there are not duplicated [Product A] under the same [Account ID]. If that can happen, you need a little bit more sophisticated approach. [Product Flag] becomes:
IF [Product A] = [Product1]
THEN 1
ELSEIF [Product A] = [Product2]
THEN 2
END
And the condition should be Count (Distinct) = 2
In both cases it will keep only the Account IDs that have both the products you selected under them. They can have other products under them.
EDIT: For the N product problem, I believe you're going to use a solution outside Tableau. One possibility is to use the JS API, so you can select the products you need in a JS interface, and pass a parameter to Tableau.
In JS you could have a list you could select as many items you want, and a script to pass a parameter to Tableau based on the selection. Could be something like: product1,product2,product3...
Then you could use CONTAINS() to see if that product is in that list (and raise a flag), and make a count of ',' to see how many products were selected.
Unfortunately I have very limited knowledge on JS API, but I strong encourage you to take a look
Really interesting question. It's surprisingly trickier to list the accounts that reference every product in a list than it is to list the accounts that reference any product in a list.
If you are willing to start with a less convenient user interface (suitable for ad-hoc analysis but not published dashboards) then try the following:
Create a filter based on Account Id, select Use all on the General tab, and By formula on the Condition tab. Enter the formula
Count(if [Product A] = "Business Office Consolidation" then 1 end) > 0 and Count(if [Product A] = "Cabled Barcode Scanner" then 1 end) > 0
This will only filter to only include Account IDs that reference both products. You can extend this to a list of any number of required products. For relational data sources, it is implemented using a HAVING clause.
Of course, it can be tedious to revise this formula by hand, but it is one way to accomplish your analysis goal, and it can be instructive to understand how filter conditions work. Similar formulas are useful for many conditions.
You can create one or more dynamic sets using the same approach and then use them in calculated fields, any shelf in Tableau and combine them to create new sets. You can also move the formula to a calculated field for convenience.
Note, the 1 in the formula is not significant, any non-null value would work. Since there is no else clause, the formula evaluates to null for rows that fail the if test. And the Count() function just counts the number of rows that have non-null values for the expression.
To come up with an approach that lets you easily select products from a list without editing a formula, will probably take some combination of more advanced features. I don't have an answer for you right now, but the features that are worth learning about that may or may not be part of the solution include filter actions, context filters, top filters, count distinct, custom SQL, computed sets, table calculations, LOD expressions and the Javascript API. This would also be a good questions to pose, with an example workbook, on the Tableau online forums at http://www.tableau.com under the Support menu.