Tableau : Filter Value - tableau-api

I have below data for a filter.
But need some rollup and create new filter list values as
Online (includes App, Desktop and Mobile) and
Offline (includes Kiosk and Pos)
Any Suggestions.

Set up a parameter (i.e., "PSource") with all of the values that you want to have (original plus groups) and make sure it is shown on your worksheet or dashboard. Create a calculated field (i.e., "CSource") where "Source" is the assumed name of the field in your data that includes your original values:
CASE [PSource Parameter]
WHEN "Online (All)" THEN IIF(FIND("App/Desktop Browser/Mobile Browser",[Source])>0,"T","F")
WHEN "Offline (All)" THEN IIF(FIND("Kiosk/Pos",[Source])>0,"T","F")
WHEN "App" THEN IIF([Source]="App","T","F")
WHEN "Desktop Browser" THEN IIF([Source]="Desktop Browser","T","F")
WHEN "Mobile Browser" THEN IIF([Source]="Mobile Browser","T","F")
WHEN "Kiosk" THEN IIF([Source]="Kiosk","T","F")
WHEN "Pos" THEN IIF([Source]="Pos","T","F")
END
Drop CSource onto the Filters shelf and select the "T" value.

Related

Creating filter in Tableau that views dataset without outliers or all data (with and without outliers)

I have a calculated field called Outlier Detection:
IIF([min_dictation_sec]>={ FIXED :AVG([min_dictation_sec])-2*STDEV([min_dictation_sec])} AND [min_dictation_sec]<={ FIXED :AVG([min_dictation_sec])+2*STDEV([min_dictation_sec])}=FALSE, "Outliers", "Not Outliers")
So this becomes a binary field that is either "Outliers" or "Not Outliers"
I created a parameter called "Exclude Outliers" because I'd like to create a dashboard filter that looks like this:
case [Exclude Outliers] when "Yes" then [Outlier Detection]="Not Outliers"
when "No" then [Outlier Detection] in ["Outliers", "Not Outliers"]
end
For "No" I want it to include all the rows. I want the aggregate of all the data in the dataset, whether or not it is an outlier.
PS - The filter has to be binary Yes or No.
Appreciate any help!
I don't think you need a parameter at all. Just place [Outlier Detection] in the filter shelf.
The filter defaults to show an All option.

ipywidgets, problem using a Text widget to filter options in a Select widget with automatic updates/ real-time interaction

I'm trying to use ipywidgets for the first time to make an interactive browser in Jupyter Notebooks of Census data using the census module. In general I'm having difficulty learning the widget library. My plan is to use the Text widget to enter a search term that will then filter the available census 'concepts' or table options (example: "Means of transportation to work") in a Selection or SelectMultiple widget. The selections made will then filter and show available data variables / columns for that census 'concept' or table (example: "car", "truck", "bus", "bike", "walk")
For reference, this first code block is what I got to work in a normal Jupyter Notebook with no widgets (at the bottom is the ipywidget attempt I'm having trouble with). I'm just starting to explore widgets and don't know anyone with experience with them. Any assistance is greatly appreciated!
*Note, running my code would require a census api key from census.gov/data/developers.html, the "Request a KEY" option on the left side menu, and change the ckey="" variable in the code below to your key. Keys are free, as it is publicly available government data.
#This section works for me as standalone code, not using ipywidgets
#Show all concepts to get an idea of search phrases to use
concepts_all = list([n for n in sorted(list([f"{t['description']}" for t in c.acs5.tables()]))]);
#This is a VERY long list, so I commented out printing it
#[print(c) for c in concepts_all]
#Apply a search phrase and limit options accordingly
concept_description_search_phrase = "Means of transportation to work by travel"
[print(f"{table['name']}: {table['description']}") for table in c.acs5.tables() if concept_description_search_phrase.lower() in table['description'].lower()]
#From the filtered options, chose one specific one to search, and display available data for it
concept_full_description = 'MEANS OF TRANSPORTATION TO WORK BY TRAVEL TIME TO WORK'
variable_filter_phrase = 'bicycle'
df = [pd.read_json(table['variables']) for table in c.acs5.tables() if table['description'] == concept_full_description][0]
acs_variable_names_list = [row.name for n,row in df.iterrows()
if variable_filter_phrase.lower() in row['variables']['label'].lower()
and 'Annotation' not in row['variables']['label']
and 'Margin of Error' not in row['variables']['label']]
acs_variable_names_list
# This is the final list I want out from a ipywidgets based workflow
# Which are variable columns, (ex: number of people in each census block group that
# have a 10, 15, 30, 45, 60+ minute commute by bicycle
########################################################
I'm having trouble getting the ipywidgets to work properly, where the Text box will interactively filter the available options in the Selection menu. I can only get it to work on a default value for the Text widget, but not off of the interactive menu. I'm basically going for the effect of the Combobox widget, but with the option to select more than one item if desired, and still see all the available options after a selection is made (so I'm thinking to use a Text and Select widget together instead of Combobox). This is my attempt so far:
out = widgets.Output()
display(out)
search_phrase = widgets.Text(
value = 'transportation',
layout = widgets.Layout(width = '900px')
)
select_multiple = widgets.SelectMultiple(
options = [n for n in concepts_all if search_phrase.value.lower() in n.lower()],
layout = widgets.Layout(width='900px',height='250px'),
ensure_option = True,
disabled=False
)
def search_change(change):
output.clear_output()
display(search_phrase)
with output:
if change.new == '':
print('new search')
return search_phrase.value
else:
print('same search')
return search_phrase.value
display(search_phrase)
display(select_multiple)
#Issue here with getting the search_phrase to properly filter options in select_multiple
#
concept_full_description = select_multiple.value[0] #Using Widgets
variable_filter_phrase = widgets.Text(value = 'bicy')
display(variable_filter_phrase) #Issue, this text box won't automatically filter the output
#it is only filtering by the default value
df = [pd.read_json(table['variables']) for table in c.acs5.tables() if table['description'] == concept_full_description][0]
acs_variable_names_list = [row.name for n,row in df.iterrows()
if variable_filter_phrase.value.lower() in row['variables']['label'].lower()
and 'Annotation' not in row['variables']['label']
and 'Margin of Error' not in row['variables']['label']] #print(row.name,": ",row['variables']['label'])
acs_variable_names_list
#This is the desired output list that will go into later workflows
I think I'm doing something wrong either in use of the .observe(), .interact(), or output /clear_output process. I'm just learning the ipywidgets and am even having trouble getting this to work in a basic example trying to follow the ipywidgets.readthedocs.io documentation.

Google DLP - Displaying the Region using InfoTypes.list()

After integrating the Google DLP API, the ListInfoTypes() currently returns the name, description, supported types of the infotypes present in the infotypes reference. Is it possible to also obtain the region for the infotypes like "Australia" or "Argentina" as a seperate field?
Currently this is my output:
"name": "AUSTRALIA_MEDICARE_NUMBER",
"displayName": "Australia medicare number",
"supportedBy": [
"INSPECT"
],
"description": "A 9-digit Australian Medicare account
I need the Region as well for example Region: "Australia" for every other infotypes.
I also got around to see locations.infoTypes.list() but I'm not sure which location I should enter in the filter to get any value.
Looking at the REST API there doesn't appear to be identifying data that can be formally used to determine the region. If we look at the InfoTypeDescription JSON structure found here:
https://cloud.google.com/dlp/docs/reference/rest/v2/ListInfoTypesResponse#InfoTypeDescription
we see that "name" is described as an "internal name of the InfoType". I wondered if we could depend on a structure of the string ... perhaps (.)*_.* as a regular expression grouping. While this might work, it shouldn't be relied upon without investigation of more samples and the docs don't describe the structure.
If you really need a solution, my recommendation would be to dump ALL the InfoTypes and then manually group the "name" fields into the regions of interest to you. You could then store this as CSV or JSON and have a reference piece of data that you could use in your app and regenerate as needed.
It's a great feature request I'll forward to the team. In the short term you can hack the name as ones that are regional will say they are in their name.

Size and contains methods of List in Drools

Is it possible write conditions on the basis of size of a list using guided editors (either guided decision table or guided rule) and to check if any element is present in the list?
For eg.
User {
List of badges;
}
now I want to apply condition on number of badges and if a specific badge is in user's list of badges.
Also can I compare to objects. For eg. condition on count of badges of two users?
I'm using KIE Drools Workbench
Here's how source code should look like :-
import com.demo.dto.User;
import com.demo.dto.Badges;
rule "Compare two variables"
when
$badge : Badges()
$user : User(name == "Sam", badges.size() >= 9, $badge memberOf badges)
then
$user.setService($user.getService() + $user.getBadges().size());
end

How do I create a manual link on a tree in Oracle APEX when Session State Protection is turned on?

Friends,
I'm facing another challenge in APEX and I hope you can help.
I have created a tree using the method described in John & Scott's superb book, "Pro Application Express" whereby the page link is stored in a table. Below is an example:
go to a page passing some parameters
f?p=&APP_ID.:3:&SESSION.::::P3_IDENTIFIER,P3_FAMILY_NAME:&P2_IDENTIFIER.,&P2_FAMILY_NAME.
When the page is run this works as expected. I can expand the tree and navigate to the page passing parameters if required.
However when I turned on session state protection these "hand crafted" links stopped working. Which I expected because the link contains no checksum.
After some investigation I see I have to use APEX_UTIL.PREPARE_URL to generate the URL with a checksum. Unfortunately this is where I run into problems. I can't seem to be able to pass the parameters values to the calling page.
The original tree query was:
select "IDENTIFIER" id,
"PARENT_IDENTIFIER" pid,
"TITLE" name,
"LINK" link,
null a1,
null a2
from <some table>
I then changed this to use APEX_UTIL.PREPARE_URL:
....
APEX_UTIL.PREPARE_URL('f?p='||:APP_ID||':3:'||:APP_SESSION||'::::P3_IDENTIFIER,P3_FAMILY_NAME:&P2_IDENTIFIER.,&P2_FAMILY_NAME.') link,
...
and this works, the page is called and I can see the values of the parameters passed. But I can't use this method as it is restricted to the one page!
Finally I tried storing the page number, parameters and parameter values in different columns of the table that the tree is based on and then bring them together:
...
APEX_UTIL.PREPARE_URL('f?p='||:APP_ID||':'||navigate_to_page||':'||:APP_SESSION||'::::'||parameters||':'||parameter_values) link,
...
Where:
navigate to page has the value of: 3
parameters has the value of: P3_IDENTIFIER,P3_FAMILY_NAME
parameter_values has the values of: &P2_IDENTIFIER.,&P2_FAMILY_NAME.
This now calls the page, but the parameter values have become literals. so where I'm expecting an identifier I see &P2_IDENTIFIER and ditto for family name.
What am I doing wrong? How can I pass values to my called page using apex_util_prepare_url?
In case of need, my environment details are: Apex 3.2.1, Oracle Application Server 10.1.2.3. Oracle Database 10.2.0.3
Thanks in advance for any help you may be able to provide.
I think you'll need to resolve those variables, using the v() function:
APEX_UTIL.PREPARE_URL('f?p='||:APP_ID
||':'||navigate_to_page
||':'||:APP_SESSION
||'::::'||parameters
||':'||v('P2_IDENTIFIER')||','||v('P2_FAMILY_NAME')) link,
On a side note, you might need to be careful about P2_FAMILY_NAME since it's being used in the url; it sounds like a plain text field which contains user-entered data?