I have a table like this:
a
b
c
1
2
abc
2
3
4.00
note c2 is text while c3 is a number.
When I do
=QUERY(A1:C,"select *")
The result is like
a
b
c
1
2
2
3
4.00
The "text" in C2 has been missed. You can see the live sheet here:
https://docs.google.com/spreadsheets/d/1UOiP1JILUwgyYUsmy5RzQrpGj7opvPEXE46B3xfvHoQ/edit?usp=sharing
How to deal with this issue?
QUERY is very useful, but it has a main limitation: only can handle one kind of data per column. The other data is left as blank. There are usually ways to try to overcome this from inside the QUERY, but I've found them unfruitful. What you can do is just to use:
={A:C}
You can work with filters by its own, but as a step-by-step to adapt the main features of query: If you need to add conditions, use LAMBDA INDEX and FILTER
For example, to check where A is not null:
=LAMBDA(quer,FILTER(quer,INDEX(quer,,1)<>""))({A:C}) --> with INDEX(quer,,1), I've accesed the first column
Where B is more than one cell and less than other:
=LAMBDA(quer,FILTER(quer,INDEX(quer,,2)>D1,INDEX(quer,,2)<D2))({A:C})
For sorting and limiting an amount of items, use SORTN. For example, you want to sort by 3rd column and limit to 5 higher values in that column:
=LAMBDA(quer,SORTN(FILTER(quer,INDEX(quer,,1)<>""),5,1,3,0))({A:C})
Or, to limit to 5 elements without sorting use ARRAY_CONSTRAIN:
=ARRAY_CONSTRAIN(LAMBDA(quer,FILTER(quer,INDEX(quer,,1)<>""))({A:C}),5)
There are other options, you can use REGEXMATCH and other options, and emulate QUERYs functions without missing data. Let me know!
shenkwen,
If you are comfortable with adding an Google App Script in your sheet to give you a custom function, I have a QUERY replacement function that supports all standard SQL SELECT syntax. I don't analyze the column data to try and force to one type based on which is the most common data in the column - so this is not an issue.
The custom function code - is one file and is at:
https://github.com/demmings/gsSQL/tree/main/dist
After you save, you have a new function from your sheet. In your example, the syntax would be
=gsSQL("select a,b,c from testTable", {{"testTable", "F150:H152", 60, true}})
If your data is on a separate tab called 'testTable'(or whatever you want), the second parameter is not required.
I have typed in your example data into my test sheet (see line 150)
https://docs.google.com/spreadsheets/d/1Zmyk7a7u0xvICrxen-c0CdpssrLTkHwYx6XL00Tb1ws/edit?usp=sharing
I'm trying to create a drop down picker that shows a list of values, but actually stores a related value.
The list I'm working with looks like:
ID Desc
AA An option
AB Different option
B3 Some other option
So I want the user to see the description, but the value stored when they have picked one is the ID column.
I've search a lot but can only find either simple data validation or dymanic (Multiple dropdows based on a prior drop down)
My users won't remember the ID's, but by having the text descriptions they will find it easier.
Any help please?
Lots of searching for clues, but can only find either simple single column drop downs, or dynamic.
Lets say, you want to select description id D7 cell then want to show result from J Column as per ID of selected description. Then Try-
=XLOOKUP(XLOOKUP(D7,B2:B4,A2:A4),I2:I4,J2:J4)
I'm looking to easily define forms with fixed-width output. Most of my forms end up looking something like this:
[title]
text
some more text
A B CDE E
-------------------------------
1 2 text text
3 4.50 text text
some more text
With all output being plain text.
Since there are many different (and yet similar) forms, I'd like to use a templating engine with a simple interface for generating fixed-width textual tables. Are there engines which support easily creating such tables? Or perhaps other ways to generate such tables?
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
Is there a way to customize the wicket DataTable layout?
I'd like to have a DataTable with a horizontal flow of data and multiple columns per row.
e.g.:
------------------------------
|prename| John| surname| Doe |
------------------------------
|city | NY | country| USA |
------------------------------
Unlike the normal use of the DataTable class this would be used for displaying just one object (respectively one dataset)
Don't use a DataTable for this.
For a simple case, just make a panel containing a Label for each data element and put the table layout in the corresponding html fragment.
To make it more dynamic, with parametrized size as noted in your comment, you might build your own structure using nested RepeatingView components, one for the rows and one for the columns, or perhaps use a DataGridView, which would do some of the layout work for you.
But DataTable is really meant for a table with meaningful columnar structure and includes alot of code for handling the column structure which won't make sense for your data and will get in your way.