As described in the overview, Natural Language Querying (NLQ) can be triggered by typing natural English questions at various entry points throughout the application. It will work against any supported database (both SQL or MDX). It's as simple as typing your question in the box and clicking the associated button or hitting the ENTER key.
Basics: Asking a Question
The following sections explain the basic elements of writing functional NLQ questions. A key aspect in understanding the depth and breadth of the NLQ engine is that the different concepts explained below and in the extended NLQ intelligence logic can and should be used in combination - allowing the user to build extremely sophisticated analytical content with fairly straight forward, plain English text.
At the most basic level the questions must include the names of one or more measures / values in the data model you're querying. Typically you would also include one ore columns / hierarchies from the model as well. These are known as "Entities" and they represent the "nouns" you are asking about as part of your analysis. For example "Show sales by product" tells the engine to find 2 entities - "sales" and "product" - and then attempt to derive a query from that selection.
If a question references multiple entities, the engine will attempt to calculate the "Cartesian" result of those entities. For example "Show sales and expenses by promotion" tells the engine to calculate a query showing "sales" and "expense" data for each of the elements in the "product" hierarchy. Extending that to "Show sales and expenses by promotion and gender" tells the engine to calculate a query showing "sales" and "expense" data in the combination of elements of the "product" and "gender" hierarchies.
The next aspect relates to question syntax. The NLQ engine is expecting normal English questions written the way a person would inquire information about their data set. For instance "What were sales and expenses this year". While the engine can be forgiving on sentence structure, there are basic syntactical elements the user needs to provide in their question.
- Spelling: While some spelling mistakes are ignored, the spelling of key entities (measure and hierarchies) is important. For instance typing in "SAL" instead of "SALES" will not produce a result. However, typing in "SALE" will work, due the intelligent word stemming framework in the engine. (see below).
- Grammar: Using correct grammar when asking your question is helpful and can, in some circumstances, drive different slightly outcomes. But its not always critical - sometimes writing keywords alone will return the desired query. Correct grammar and use of prepositions will ensure that your question is interpreted most correctly, and the right result is returned. For instance, if you want to know product sales over the last 4 quarters, write "what were product sales over the last 4 quarters?". Writing "product sales last 4 quarters." may not produce the same result.
- Punctuation: While adding punctuation to your questions is also helpful, it is not critical. This includes commas, question marks and periods. Generally the engine is not sensitive to case, However, Proper casing names of geographic locations or names of people can provide the engine with a stronger hint that the item is a Proper noun. Both of these elements are used in the advanced query intelligence.
The engine's internal smarts includes the ability to "stem" words or find known derivatives of a word to identify entities or other key words and phrases. Word stemming does not correct spelling issues, instead it solves the variations used by people to describe the same common thing. (However, this is not the same as finding related words like a thesaurus). For instance typing in "EXPENSIVE", the engine will attempt to find something called "Expensive", failing a direct hit, it will stem expensive and look for "Expense", "Expenses" etc. If you had a measure called "Expenses", the following would return a successful result "Show me the most expensive countries".
In addition to the word stemming capabilities, the NLQ engine includes a thesaurus - allowing users to type words that may NOT exactly match entities or key operations. Instead, the engine will ask the thesaurus for alternatives and attempt to use those in addition to the supplied syntax to find the best fitting query. Words from the thesaurus may also be run through the stemming engine above. For instance typing "Merchandise", the engine may find something like "Product" (stemmed to "Products"). Using "postcode" can be used interchangeably with "zip or "zip code", or typing in "sex" may be swapped out to "gender".
As users type questions into the search bar they will be prompted with entities from the underlying data model and keywords. Users can then use the keyboard (down or up arrows) or their mouse to pick the suggestion rather the type the terms. In the even the user wants to drop the full list of items the following short cuts are available:
- "**" - will produce a list of all hierarchies and measures
- "*m" - with produce a list of all measures
- "*h" will produce a list of all hierarchies.
By default, the engine will draw the results of questions using the smart visualization engine, which uses augmented logic to resolve the best way to draw your results. However, you can instruct the engine to draw a specific visual by including the plain name of the chart type in the question text such as: grid, column chart, pie, line chart etc. For example "Show me sales by month in a grid".
- To tell the engine to use the AI-suggested visualizations instead, use phrases like "recommend a visual" or "redraw" in the chat bot.
- Click here for more details on how the visualizations work and overriding the automated choices.
You can add sorting to your query by using phrases such as: highest, lowest, most, least, ascending, descending. For example "Show highest products by sales" will do a descending sorted list of products using the sales metric. "products by sales, descending" and "Which product had the most sales?" will achieve the same outcomes.
Note: By default all sort commands are descending.
You can add numeric filtering to your query by using phrases such as: Top x, Bottom x. For example "Show top 15 products by sales" will do a descending sorted list of top 15 products using the sales metric.
Beyond the basics described above, the NLQ engine has specialized capabilities for handling dates and time; geospatial entities; and proper nouns. Understanding how these are accessed and how they work can greatly expand the functionality of NLQ for users.
- Click here for more details.