I am trying to allow sorting a wiki table that use the "sortable" class by multiple columns.
Eg:
{| class="wikitable sortable"
|-
|Col 1
|Col 2
|Col 3
|-
|3
|a
|tee
|-
|2
|c
|hot
|-
|5
|b
|apple
|}
That will give you a basic sortable table on the wiki, but it won't let you sort by multiple columns.
Does anyone know of a way to do this or of an extension I can install that will allow me to do this?
Wiki sortable tables seem to already give the ability to multi-sort tables natively / without extension.
After clicking the first column to be sorted, press and hold shift key then click on other column headings for the next columns to be sorted. (Reference 1 2)
I am not sure this function is already there when this was asked, but this StackOverflow question seems to pop on search results more often than the article itself.
You can find any JavaScript code on the web for sortable tables and put that code in your user JavaScript or site Javascript. This simple one works because somebody has already added code for single column sortable tables which looks for tables of class "wikitable sortable".
Related
I have a couple of joined Athena tables in Quicksight. The data looks something like this:
Ans_Count | ID | Alias
10 | 1 | A
10 | 1 | B
10 | 1 | C
20 | 2 | D
20 | 2 | E
20 | 2 | F
I want to create a calculated field such that it sums the Ans_Count column based on distinct IDs only. i.e., in the example above the result should be 30.
How do I do that?? Thanks!
Are you looking for the sum before or after applying a filter?
Sumif(Ans_Count,ID) may be what your looking for.
If you need to always return the result of the sum, regardless of the filter on the visual, look at the sumOver() function.
You can use distinctCountOver at PRE_AGG level to count unique number of values for a given partition. You could use that count to drive the sumIf condition as well.
Example : distinctCountOver(operand, [partition fields], PRE_AGG)
More details about what will be visual's group by specification and an example where there duplicate IDs will help give a specific solution.
It might even be as simple as minOver(Ans_Count, [ID], PRE_AGG) and using SUM aggregation on top of it in the visual.
If you want another column with the values repeated, use sumOver(Ans_Count, [ID], PRE_AGG). Or, if you want to aggregate via QuickSight, you would use sumOver(sum(Ans_Count), [ID]).
I agree with the above suggestions to use sumOver(sum(Ans_Count), [ID]).
I have yet to understand the use cases for pre_agg, so if anyone has concrete examples please share them!
Another suggestion would be to do a sumover + partition by in your table (if possible) before uploading the dataset, then checking if the results matche with Quicksight's aggregations. I find Quicksight can be tricky with calculated fields, aggregations, and nested ifs so I've been doing calculations in SQL where possible before bringing it in to quicksight to have a better grasp of what the outputs should look like. This obviously is an extra step, but can help in understanding how quicksight pulls off calcs and brings up figures (as the documentation doesn't always give much), and spotting things that don't look right (I've had a few) before you share your analysis with a wider group.
I'm not sure if this is obvious and I don't see it because it is late here, but right now I'm struggling with the following:
I'm trying to find out if there is a match somewhere. So, profile 2 liked profile 1 and also, profile 1 liked profile 2. That would be a match.
I tried combining arrays but that that ran nowhere. ._. How could I archive this in Laravel queries?
$likey = DB::table('likes AS liker')
->join('likes AS liked', 'liker.liked_id', '=', 'liked.liker_id')
->select('liked.liker_id', 'liked.liked_id')
->where('liker.liker_id', '=', 'liked.liked_id')
->get();
Something along those lines.
EDIT: Just to clarify this solution so you don't get into temptation of copy pasting this and never figuring out what just happened here;
we are joining (using INNER JOIN, very important) this table to itself simpy because (just like you've said it) we have to check it twice. First for the liker (the one who liked someones profile first), than for the liked (the one who responded with a like in return) user. Having that in mind, we join this table checking liked_id from the first table on liker_id on the second table.
Which should give us joined result looking like:
liker.liker_id | liker.liked_id | liked.liker_id | liked.liked_id
-----------------------------------------------------------------
2 | 1 | 1 | 2
1 | 2 | 2 | 1
Mind you this will give us duplicates! (VERY IMPORTANT).
Having that in mind I would think about redisigning your table. For example adding boolean column named "liked_back" will give you much cheaper and cleaner queries rather than doing whatever this is...
I using laravel 5.1 and PostgreSQL.
I have data product, and I want to custom the order by myself.
For example, I have product
{A, B, C, D, E, F}
and I want to show them in a table by what I want
Idx | Item
-----------
1 | A
2 | C
3 | E
4 | B
5 | F
6 | D
To do this I need a page that can setting it right?
My problem is I don't know what page must I develop to create setting order.
Maybe a page that has a table that I can move each row to set the order,
and a database field in item table to save the order setting?
Please someone help me, is there a plugin like that?
You can just create a page that list all items with minimal amount of information. Then you change the order use something like jQuery UI sortable or Dargsort to sort them, and then save the index of the list back to your database as custom index
But keep in mind 100 items is still too many, it would be much better to just provide filter of all attributes to display items in different order.
Is it possible to easily distribute data ('subject's in my case) into different columns based on the value of another field ('block' in my case) so I could have a kind of timetabling grid report, i.e.
if my data looks like:
Subject | Block
----------
English | A
French | B
Science | C
----------
x | A
y | B
z | C
How might I produce a table / matrix that looks like:
Block A | Block B | Block C
English | French | Science
x | y | z
(forgive the formatting!)
I can't help thinking this must be straight forward, but I can't seem to find the appropriate technique. Something like a pivot, but listing rather than aggregating values? I thought maybe filtered columns, but that doesn't seem very efficient. Many thanks for any advice!
Using the following as a basis
https://stackoverflow.com/a/9007678/2311633
(I have copied the relevant sections so the complete answer is on this page...)
You can create a horizontally expanding table by:
First create a Tablix by dragging the Matrix Report Item onto the design surface. The Tablix will have a RowGroup and a ColumnGroup by default.
Delete the Row Group by right clicking on it and selecting "Delete Group" In the Delete Group prompt, delete both just the group. (Not related rows and columns; you'll probably want these as left label for your rows.)
At this point right click the Column Group and "Add Group -> Child Group...". Keep adding child groups for each of the rows you require. For each child group select 'Group by' and choose each of the series you wish to display on each individual row.
I am unable to post images at this time, but have been able to recreate what you have requested above. Once I'm able to I'm can post screenshots for further clarification if required.
Update
Alternatively, If you are able to edit the SQL source could you add another field to define a row number for each item. Using ROW_NUMBER() and PARTITION_BY you could add a new column such as
SELECT ROW_NUMBER() OVER(PARTITION BY [Block] ORDER BY [Block]) as rownum
Then you could just create a simple Matrix as shown here https://www.flickr.com/photos/135805284#N08/20883237722/
I want to display the table in the below format. How can I achieve this?
---A----+-----B-----+----C-----
12335 | abcd | qwerty
45335 | efgh | poiuy
78956 | hjukukuk | mkloijhkll
12346 | sfsfsf | vbhkhadad
EDIT 1:
The contents of the table can be of any length. The width of the particular cell has to be decided by the content itself.
I got the column width from
col_width = a.transpose.map{|col| col.map{|cell| cell.to_s.length}.max}
and displayed the table contents with:
a.each{|row| puts '['+
row.zip(col_width).map{|cell, w| cell.to_s.ljust(w)}.join(' | ')+']'}
where 'a' contains the data from the database.
I only cannot get to print the column headers.
How i can achieve those so that it can align with the table cell contents.
I need to display the output in the console. I am using OCI for accessing the database.
The Sequel ORM can do this using the pretty_table extension. Otherwise HIRB is capable of doing it, either with ActiveRecord, or from arrays/hashes.
I use Sequel often, and have occasional need to display a table summary on the console, so pretty_table works nicely for me.
HIRB is used in the irbtools plugin for IRB, and provides table output for all sorts of things.
In either case, the displayed table width is dynamically determined using the lengths of the strings being displayed to find the widths of the columns. I've never tried pushing really long strings through either that would require wrapping inside a column, but they should automatically handle that since it's a common requirement.
I wrote a gem that will help you with this: http://github.com/arches/table_print