Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Tabular data/doc
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <code>lookup</code> == Returns the value of the cell(s) in one or more output columns of the row matching the search key and column. This function is reminiscent of <code>LOOKUP()</code> macros in popular spreadsheet applications, except that the search key must match exactly. (On the other hand, this means the table does not need to be sorted.) Usage: {{mlx|{{BASEPAGENAME}}|''lookup''|''Page name.tab''|search_value{{=}}''Value to find in column''|search_column{{=}}''Name of column to search in''|output_column{{=}}''Name of column to output''|output_column2{{=}}''Name of another column to output''|output_column''n''{{=}}β¦|output_format{{=}}''[[mw:Extension:Scribunto/Lua reference manual#string.format|String format]] to format the output''}} If multiple columns are output without an explicit string format, this function formats the output as a human-readable list. Some may find {{tl|Tabular query}} (which uses this module) an intuitive way to obtain cell data as it resembles a simple [[SQL]] query. === Parameters === ; {{para|1}} : Page name on Commons with extension but no namespace ; {{para|search_value}} or {{para|search_pattern}} : Value to find or [[mw:Extension:Scribunto/Lua reference manual#Patterns|pattern to match]] in column ; {{para|search_column}} : Name of column to search in ; {{para|occurrence}} : Index of the match to output in case of multiple matching rows. A row index of <code>1</code> refers to the first matching row. A row index of <code>-1</code> refers to the last matching row. It is an error to specify a row index of <code>0</code>. ; {{para|output_column}} or {{para|output_column1}}, {{para|output_column2}}, ... : Names of columns to output ; {{para|output_format}} : [[mw:Extension:Scribunto/Lua reference manual#string.format|String format]] to format the output === Examples === Total confirmed case count in [[c:Data:COVID-19 cases in Santa Clara County, California.tab]] on the day that the county issued a [[stay-at-home order]]: {{#invoke:Demo|module|demo_module={{BASEPAGENAME}}|demo_module_func=lookup|COVID-19 cases in Santa Clara County, California.tab|search_value=2020-03-16|search_column=date|output_column=totalConfirmedCases}} The last day that a hundred or more patients with COVID-19 were in the hospital in [[c:Data:COVID-19 cases in Solano County, California.tab]]: {{#invoke:Demo|module|demo_module={{BASEPAGENAME}}|demo_module_func=lookup|COVID-19 cases in Solano County, California.tab|search_pattern=%d%d%d|search_column=hospitalized|occurrence=-1|output_column=date}} Total number of administrators on all Wikimedia wikis using [[c:Data:Wikipedia statistics/data.tab]]: {{#invoke:Demo|module|demo_module={{BASEPAGENAME}}|demo_module_func=lookup|Wikipedia statistics/data.tab|search_value=total.all|search_column=site|output_column=admins}} Number of administrators and users on all Wikimedia wikis using [[c:Data:Wikipedia statistics/data.tab]]: {{#invoke:Demo|module|demo_module={{BASEPAGENAME}}|demo_module_func=lookup|Wikipedia statistics/data.tab|search_value=total.all|search_column=site|output_column=admins|output_column2=users|output_format=%d out of %d users are administrators}} ''Note: Wikipedia statistics are shown as an illustration only. In practice, there is a high-performance module {{tlx|NUMBEROF}} to access Wikipedia statistics.''
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)