Highlighting Via Parameter In Tableau - tableau-api

I have created a parameter using Tableau 10.2 on one of my data field name as
"Region". This is a string and i have selected a list option.
To call this i have created 2 calculated fields:
[Group Highlight] this is one calc field which has name of my parameter.
The other calculated field is
CASE [Group Highlight]
WHEN [Assigned Group] THEN [Group Highlight ] ELSE "Others" END
What i am trying to do when a user selects a specific group that region/group should appear in separate color when i will place this field on color by option. However i only get Others.

Related

Filtering Based on a Different Column on Tableau

I'm wondering if something like this is possible.
Assume I have a data table like this:
I want a filter, where user picks France for example, but the data is filtered based on corresponding Continent value, e.g., all Europe records should show up.
Is this possible?
Sure, We can do that. If you add country to Filters shelf, Tableau will show only records of selected value. In our case, if we filter "France", Tableau shows only records which has France. So we will miss other Europe records. Parameter can handle this scenario. Follow below steps.
1.Create a String parameter
2. Create a calculated field
3. Add the created calculated field to Filters shelf then choose 'show'
4. Right click parameter then 'Show parameter control'. So it will works like filter
Method 2: Dynamically change parameter value
Pros: No hard coding, dynamically changes value based on selection. It works, well on dashboard
Cons: You will not have drop down for selection like filter. So, you need to click a chart to trigger the changes.
1. Create a String parameter with allowable values as 'ALL'
2.Create a calculated field
3.Create a parameter action in dashboard.
Dashboard-> Actions-> Add Action -> Change Parameter
In Change Parameter dialogue box, set target parameter as 'Parameter Name' and value field as 'Continent'
4. Add the calculated field to filter and select 'True' on other sheets
5. Final Dashboard looks like
Click the icon on the selector sheet. It will automatically filter data on data sheet.
Inside the selector sheet

Parameter Dependency

I have a report with the following parameters: Start Date, End Date, Group 1, Group 2. What I am trying to accomplish is to do a parameter dependency on Group 2 meaning if I select Group 1 parameter for Customer service, it will only show list of Group 2 parameter related to Customer service.
I tried to create a parameter for Customer Service and Sales then created a calculated field that when a value is selected Group 2 parameter is automatically refreshed, but epic fail. I created a calculated field using this code, but didn't work at all. IF [Group1] ="Customer Service" THEN [CS] ELSEIF [Group1]="Sales" THEN "SL" END Note that the 'CS' and 'SL' are the parameters I created containing the Group 2 drop down list below. Please advise.
Sounds like these need to be filters instead of parameters. Show the quick filter for Group 1. Show the filter for Group 2. In the Group 2 quick filter settings, choose Only Relevant Values. That way the group 2 will only list values based on what you select for group 1.
This is absolutely possible through CASE functions
Although note this about fields and parameters, parameters determine the fields or the values in the fields to show. You can't have a formula that returns a parameter
To me this doesn't make sense:
IF [Group1] ="Customer Service" THEN [CS] ELSEIF [Group1]="Sales" THEN "SL" END
The reason being that your THEN is a parameter, not a field
A simple way of doing this is:
1) You need 1 parameter for group 1 with string values for Customer Service and Sales
2) You then need to make a field for each value you want to group. Example of the field "IF [Group 2] CONTAINS("CS REGION") IS TRUE THEN [Group 2] END"
For the Sales field: "IF [Group 2] CONTAINS("Sales") IS TRUE THEN [Group 2] END"
Here is an example of the field to plug into the table using parameters that works correctly:
CASE [Group parameter]
WHEN "Customer Service" THEN "Group 2 CS field"
WHEN "Sales" THEN "Group 2 Sales field"
END

Tableau: custom grouping by string

I’ve got data that looks like this:
Drug name:
Methylphenidate
Methylphenidate
Acetaminophen
Ritalin
Ritalin
Tylenol
Tylenol
I want tableau to treat “Ritalin” as “Methylphenidate”, and “Tylenol” as “Acetaminophen” for all purposes. I'm ideally hoping someone will point me to a menu or calculated field script where I can write out a long list of string substitutions. The full data set will have about 50 such changes to make.
For this example, I’m trying to count the number of times Methylphenidate/Ritalin is prescribed, and the number of times Acetaminophen/Tylenol is prescribed. Here, I want the output to be Ritalin = 4, and Tylenol = 3.
The only solution I can think of is to go into the data source, duplicate the "Drug name" column and run a "find and replace", but that's inelegant and would need to be repeated when data is added.
Thanks for the help.
If you are mapping multiple values to a single value (rolling them up), then use a Tableau group. The easiest way is to:
put Drug Name on the rows shelf
multi-select (shift-select) values that you want to combine
click the paperclip icon on the toolbar to group them together
right click on the resulting combined name and set a shorter alias of your choosing
The effect is to create a new group field based on the original Drug Name field that acts like the calculated field #Aron defined.
If instead you want to map each individual value to its own distinct label (say to display a meaningful name instead of a short cryptic code from the database), then you can create aliases instead of a group.
No problem. You can do this with a simple calculated field. Create a new calculated field and follow this logic
if [NDC Description] = 'Abilify' then 'user1791903'
elseif [NDC Description] = 'Actos' then 'user1791903'
elseif [NDC Description] = 'Actonel' then 'user1791903'
elseif [NDC Description] = 'Acyclovir' then 'Group2'
elseif [NDC Description] = 'Aciphex' then 'Group2'
else 'Unknown'
end
Basically, this will evaluate each record and depending on whether NDC Description is X or Y, it will output "user1791903" or "Group2" or "Unknown" if the record doesn't match any of the text you entered. Then, you can drag this calculated field to the shelf and it will display using this grouping, and you can then add aggregate functions and whatever else you need.
All these responses were very useful. The solution I ended up using:
I created a separate spreadsheet with a list of drug names and their generics. Then I ran a table join, adding it to the large dataset. This approach was valuable as it allowed me to easily add and edit drug definitions later on, and even add more metadata.
Thanks to everyone.

Filemaker 12 -- display one value, store another

I'm building a database in FileMaker 12 that will, among other things, keep a list of jobs (indicated by numeric ID) and the employees who had billable time for that job.
Given three tables:
Employee ( empName, empID, salary, ... )
JobHours ( empID, jobID, hrsWorked, ... , refID)
JobCost ( jobID, expenses, profit, ... , refID)
Where:
Employee is my personnel roster matching names to numeric employee IDs and stats (salary, et al) ;
JobHours is a list of employee participation -- whenever an employee spends time on a job, this table has a line that shows their ID, the job ID, hours worked, and a few other things;
JobCost is a daily record of jobs. One entry in this table refers to the activity for a single job on a single day. Additionally, each entry gets a system generated unique ID (since neither jobID nor date is unique) to relate to JobHours (resulting in a list of who worked on a particular job on a particular day).
I have a form showing records from JobCost. For each record, I can see in a portal, showing records from JobHours, who worked on that job on that day.
Now, the issue.
In my portal, I want to have a drop-down list of employee names pulled from a value list to create records in JobHours with the following criteria:
1) I need it to be a drop-down rather than a pop-up so it will respond to auto-fill from the keyboard. A drop-down will show the secondary value (employee name) from a value list while dropped down, and will respond properly to keyboard autocomplete on the secondary value, but once you've made your selection, it only displays the primary value (employee ID).
2) I need it to display names, not IDs, at all times. The pop-up does this perfectly. However, it doesn't seem to respond to the keyboard for typing autocompletes.
3) I need to store the numeric ID rather than the name.
I know how to satisfy any two of these criteria at once, but that's all. The whole database is working beautifully otherwise. Is this behavior possible?
One common technique is to use two fields, one directly on top of the other.
On the bottom, put your JobHours::EmpID field. Set it up as the drop-down list with the value list that you've specified.
On top of the JobHours::EmpID field put the related Employee::EmpName field. Set the field so that it cannot be entered in browse or find mode.
Now your users will see the Employee Name, but when they click that click will go through the top field and into the Employee ID field where they will choose the name from the value list.
pft's solution is one that I have long used, but I do still find it inelegant because the user still sees an existing id number in the field when changing the value.
If the type-ahead is important, I would use the popup menu. Once the menu has been activated either by tabbing into it or by clicking into it, the user is able to type from the keyboard and the selection will change based on what's entered.
I came to this thread looking for a solution to this same issue (allowing the user to pick from a list, show their choice, but store a related value instead). For example, choose a plant species name from a dropdown, show the plant species name in the dropdown field, but have it store the taxonomic serial number (TSN; which is more likely to stay the same over the years). This is easy to do in MS Access, but took a litlte more messing around to do it in FMP12.
How I solved it:
I created two fields in the table that would be storing the values: Plant_TSN and Plant_SciName. A relationship must exist between the values in these two fields. In my case, I store a SciName for each TSN in a lookup table. I then created two fields in my layout, one for each new field.
For the value you wish to store (ex. Plant_TSN):
Make the corresponding layout field a dropdown and include the show/hide arrow. Edit the value list you will populate the dropdown with to show the second (reader friendly) column but store the first column value. In the layout shrink the field to only show the arrow.
For the field you wish the user to see (ex. Plant_SciName):
make the other layout field a Edit Box and prevent field entry in either Browse or Find mode. But it up against the dropdown arrow created in the previous step to make what looks like one field.
Finally, back in the first field (arrow-only drop down) write a script to push the user friendly number (Plant_SciName) to the edit box when the user-ugly (Plant_TSN) value is picked in the drop down. I used the OnObjectSave script trigger of the dropdown formatted field. Script should be something along the lines of 1) Freeze window, 2) Go to Related Record (based on relationship in lookup table 3) Set Field (i.e. the edit box) and 4) GotoLayout[original] to offset the Freeze.
Probably not an entirely clear explanation, but I bet you will get it on your third read through! I would have posted a screenshot, but I apparently need 10 "reputation points".
Cheers.

Dynamic parameters in Crystal report

I have a LINETYPE parameter with the following values:
INV_DEVICE
INV_SIM
TAX
OTHER_ITEMS
If the user chooses anything from the LINETYPE parameter anything that start with "INV_*", is it possible that another parameter field be populated dynamically?
For example, the user chooses INV_DEVICE. There would appear another parameter field called GOODSTYPE.
Values for GOODSTYPE are taken from the database. Example:
PAGER
GSMPHONE
SMARTPHONE
TABLET
But when the user chooses TAX or OTHER_ITEMS the user does not need to choose any value from GOODSTYPE, or the parameter field does not show at all.
The output of the report are those matching the criteria the user entered.
Note that for LINETYPE and GOODSTYPE, user can choose multiple values.
LINETYPE is a mandatory field, but GOODSTYPE will vary upon the values chosen by the user in LINETYPE
What you really want is call Cascading Parameters. The first selection leads to a refined list on the second selection which leads to another refined list, etc. Like Country -> State/Province -> City.
I don't use it but from what I gather, your selection needs to be stored in a table. To create a Cascading Parameter:
Create a new parameter
Under List of Values, select Dynamic
Select your value, description and Paramter
Set the option for Allow Multiple Values
repeat step 3-4 if you have more parameters.