How to make a Splunk Dashboard dynamic? - splunk

I have a query lets call it query1 that looks at sales and I have storenumber=1 in that query I have query2 that looks at returns with storenumber=1 in the second query
I want to add these queries to my store's dashboard. Now in the dashboard, I want to have a box (text, dropdown, anything) where I can enter a new store number and run both those queries.
If I enter say 2 in that box how does that 2 get replaced in the queries where store number =1 to be storenumber=2 now?
I thought it would be some token like variable? but I'm not sure how to get that to work so that the number entered is populated where the storenumber= is in the queries?
Any help will be appreciated
Thank You

It is a token-like variable. When you create your input (dropdown, text, etc.) is it given a name. The value of that input is referenced simply by putting the token name within $s.
... | where storenumber = $store$ | ...

Related

Syntax for adding to this T-SQL Query

I built a simple UI for our users to query on our SQL Server DB. The UI started off as just one input field for a person's name. This field's input would be used to search on 3 fields on our database. The query up until now looks like this:
SELECT [Id], [Url], [PersonName], [BusinessName], [DOB], [POB], [Text]
FROM dbo.DataAggregate
WHERE CONTAINS([PersonName], 'NEAR((john, doe), 2, FALSE)')
OR CONTAINS([BusinessName], 'NEAR((john, doe), 2, FALSE)')
OR CONTAINS([Text], 'NEAR((john, doe), 2, FALSE)')
The above assumes the user queried on John Doe. The requirement for NEAR has to do with the format inconsistencies across data in our fields, but that's not relevant to this question, just an FYI.
Now, I've been instructed to add 4 more input fields in the UI to allow users to further tailor their query. These fields already exist in the DB records. My question is how do I add on to the above query for when the additional fields in the UI are used? Am I simply just adding several AND statements to it or OR statements to it?
Let me give an example to help you help me:
User Query:
Person Name: John Doe
DOB: 01/01/1900
Address: 123 Main St
POB: USA
Occupation: Worker
How would I add to my query to include the data for the other 4 input fields? Initially, to handle which input fields are populated and which are not, do I need IF statements in the query?
Each value in the other 4 input fields would need to be searched for in its own field, plus the Text field - i.e.
-The DOB would need to searched for in the DOB field and Text field
-The Address would need to searched for in the Address field and the Text field
etc.
It just seems there has to be a more efficient way to structure a query like this than having basically 5 sections similar to my above query separated by IF/AND/OR.
Thank you.
If you use parameters you can get round unpopulated inputs with this trick
Where
((#input1 is null) or (somefield = #input1))
Or / And
...
This is going to get messy real quick though, they'll come up with more inputs next week.
Other options
Grid with Filter capability.
Data dump for say Excel
Building the query programatically, with parameters.

Group similar records by same ID in access

I have a table full of clients in access and some are similar to each other (eg. NBC6, NBC10, etc.) I was wondering if there was a way to group all the similar clients and assign them all 1 ID. They would all start off the same so I was thinking to search for them like that but I'm unsure how to go about this in VBA. I am rather new to access and SQL so any help would be greatly appreciated!
Create a new field in your table called ClientGroup. Set its datatype to Text.
Get a list of all ClientGroup names you want to use. Let's say, for example, that NBC6 and NBC10 should end up in one group called NBC.
Run an Update query to assign that group:
UPDATE tblClients
SET ClientGroup = "NBC"
WHERE ClientName LIKE "NBC*"
The asterisk sign acts as a wildcard, so it will only update the records where the first 3 letters of ClientName are "NBC".
It's a lot of manual work, I suppose if you know you always want to use just the first 3 characters of a ClientName you can write a loop to put them in an array, but that's probably not the case.

Select certain rows from a result set. MS Access VBA

This could be bit complicated. I will try to explain as much as I can.
Say for example i have a table called "Job". In this table there will be multiple entries for a same Job ID (Job ID is not Unique). The current system enables a user to search for a particular Job ID and return all the rows having the same Job ID on a form as shown below:-
Job ID | Item Name | Date Completed | Generate Report?
------------------------------------------------------
JB001 Door 25/12/2012 []
JB001 Window 02/01/2013 []
JB001 Blinds 10/01/2013 []
JB001 Carpets 15/02/2013 []
I would like to implement a feature where a user can select multiple rows from this result set (using the check boxes) and generate another form/report form he selections. For e.g. if the user ticks check boxes next to Window an Blind and then clicks a button, the next form should display these selected rows.
By the way, I am using MS Access.
The problem I am facing is haven't got a clue as to how to implement this i.e to select certain rows from the result set.
Thanks in advance.
Perhaps youre thinking in too much code, could you formulate a query that uses the job ID from a form and the check box as a where condition?
You could base the report off of the query and as long as the form is open when the report is opened the query can use its fields. In the where box type [Forms]![frmFormName]![FieldName]
That should get you started.

using a lookup table on a form with Oracle Apex Item

I have an application that uses Oracle Apex 4.2 . It has a form ( form and report on a table) that needs to display descriptions for columns on the table. For instance, there is a column on the table called fund which has a numeric value ( 1 to 6). There is a separate table that gives a description for each of these 6 values. Under EDIT PAGE ITEM, under SOURCE, I chose SOURCE TYPE -> SQL QUERY
I entered this query below:
SELECT DESCRIPTION FROM
"#OWNER#"."BU19ANT",
"#OWNER#"."FUNDCD"
WHERE ANTFUNDCD = CODE
where BU19ANT is the table that used for this form
FUNDCD is the name of the look up table
ANTFUNDCD and CODE and numeric fields on the respective tables and DESCRIPTION is the value that I want to look up and display on the form.
This gives me the correct answer MOST of the time, but not all the time.
The key to the table ( and the field used to link from the report to the form) is the Soc Security Number. If I run this same query against the Oracle table hard coding the SS Number, I always get the correct answer.
This form has 5 look ups that work this way and they all have the same problem.
I assume that I DONT need to include the Social Security Number as part of the query Apex already knows that.
But I tried to add that and can not figure out how to code it.
I tried
WHERE ANTSOCIALSECURITYNUMBER ( column on table) = P2_SOCIALSECURITYNUMBER ( the item on this page)
but that gave this error
ORA-00904: "P2_SOCIALSECURITYNUMBER ": invalid identifier
Is there some other way to code this? Or to say where SS Number = current record?
Or am I on the wrong track here?
Try :P2_SOCIALSECURITYNUMBER (for items on session) or &P2_SOCIALSECURITYNUMBER. (for items on page)

Nested Lookup Functions? Need to match up two things

So I'm working in microsoft sql server report builder and here is essentially what I'm trying to do in code:
(Under report variables)
vChargeStatusID = Lookup(Fields!CREDIT_CARD_TRANSACTION_ID.Value, Parameters!CREDIT_CARD_TRANSACTION_ID.Value, Fields!CHARGE_STATUS_ID.Value, "DataSet1")
(As an expression for a filter)
Lookup(Variables!vChargeStatusID.Value, Fields!CHARGE_STATUS_FK.Value, Fields!CONTRACT_NUMBER.Value, "DataSet1")
I've tried using the variable and the expression for the variable to try to create another calculated field, but no luck. I keep getting the error that I can't use nested lookup functions.
Basically what I'm trying to do is, first, find two things that are equal to each other to retrieve a number. Then I need to take that number and match it to something else to finally return the contract number.
I cannot figure this out.
Any help would be great.
So, a very simple way to accomplish this is to place a field on your report (TextBox1.value) that will hold your first lookup value.
For example, your first look up will return a vendor ID (DataSet2) from a customer order (DataSet1).
TextBox1.expression = Lookup(Fields!CustOrderID.Value,Fields!CustOrder_ID2.Value,Fields!VendorID.Value,"DataSet2")
But now you need to find the vendor name from a Vendor Master table (DataSet3). You can do another look up to the Vendor Master table using the ReportItems!TextBox1.value as the first value of the look up. That way you do not get the scope issue.
TextBox2.expression = Lookup(ReportItems!Textbox1.value,Fields!VendorID.Value,Fields!VendorName.Value,"DataSet3")
All credit goes to my boss who figured this out!
Step one: Create another dataset, which is embedded. This dataset then has a filter that takes a field, in this case it's CREDIT_CARD_TRANSACTION_ID, and evaluated it be true to the parameter, pCreditCardTransactionID. This makes sure that the second dataset is ONLY going to display to me the Contract number, which is the very last thing I needed from the Lookup Function.
Step two: Create an internal parameter that the default value is set to the field CONTRACT_NUMBER from the second dataset (ContractNumberLookup).
Step three: Create a filter on the table. The CONTRACT_NUMBER from the original dataset is set to equal the internal parameter.
Tada!
I hope this helps. If any clarification is needed, let me know!