in QuickSight, how can I apply a wildcard to a string in a calculated field of type ifelse? - amazon-quicksight

in QuickSight, how can I apply a wildcard to a string in a calculated field of type ifelse?
for example
company = netflix - ID 3, netflix - ID 5, netflix - ID 7
I want to apply a ifelse condition regardless of the ID number
ifelse({company}= "netflix - ID * ", "https://reportest.s3.amazonaws.com/netflix+logo.png", "error")
this last one doesn't work. How should be the correct thing to apply a wildcard?
Thanks

Related

How to Select multiple related columns in add calculated fields in Quicksight parameter using ifelse?

I have a parameter 'type' in a table and it can have multiple values as follows -
human
chimpanzee
orangutan
I have 3 columns related to each type in the table -
human_avg_height, human_avg_weight, human_avg_lifespan
chimpanzee_avg_height, chimpanzee_avg_weight, chimpanzee_avg_lifespan
orangutan_avg_height, orangutan_avg_weight, orangutan_avg_lifespan
So if i select the type as human, the quicksight dashboard should only display the three columns -
human_avg_height, human_avg_weight, human_avg_lifespan
and should not display the following columns -
chimpanzee_avg_height, chimpanzee_avg_weight, chimpanzee_avg_lifespan
orangutan_avg_height, orangutan_avg_weight, orangutan_avg_lifespan
I created the parameter type and in the add calculated fields I am trying to use ifelse to select the columns based on the parameter selected as follows -
ifelse(${type}='human',{human_avg_height}, {human_avg_weight}, {human_avg_lifespan},{function})
I also tried -
ifelse(${type}='human',{{human_avg_height}, {human_avg_weight}, {human_avg_lifespan},{function}})
And -
ifelse(${type}='human',{human_avg_height, human_avg_weight, human_avg_lifespan},{function}})
But none of it is working. What am i doing wrong ?
One way to do this would be to use three different calculated fields, one for all the heights, one for weights and one for lifespan. The heights one would look like this:
ifelse(
${type}='human',{human_avg_height}, ifelse(
${type}='chimpanzee', { chimpanzee_avg_height}, ifelse(
${type}='orangutan',{ orangutan_avg_height},
NULL
)))
Make another calculated field for weights and lifespan and then add these calculated fields to your table, and filter by type.
To make it clear to the viewer what data is present, edit the Title of the visual to include the type:
${type} Data
You have to create one calculated field for each measure using the ifelse with the type to choose the correct vale, but is not necessary to create inner ifelse as skabo did, the if else syntax is ifelse(if, then [, if, then ...], else) so you can define the calculated fields as follows:
avg_height = ifelse(${type}='human', {human_avg_height}, ${type}='chimpanzee', {chimpanzee_avg_height},${type}='orangutan', {orangutan_avg_height}, NULL)
avg_weight = ifelse(${type}='human', {human_avg_weight}, ${type}='chimpanzee', {chimpanzee_avg_weight},${type}='orangutan', {orangutan_avg_weight}, NULL)
avg_lifespan = ifelse(${type}='human', {human_avg_lifespan}, ${type}='chimpanzee', {chimpanzee_avg_lifespan},${type}='orangutan', {orangutan_avg_lifespan}, NULL)
Then use those calculated fields in your visuals.

How do I create a filter using just one field where the drop down list shows grouped items from the field in Amazon Quicksight?

I need to make regional groups from a 'Company' field in Quicksight. How do you create a filter that will show grouped companies? For example Region 1, Region 2, Region 3, etc. Each of these groups when chosen in the filter will need to show a specific list of companies from the one field 'Company' based on the Region chosen.
I've tried creating separate parameters (Region 1, Region 2, etc.) with the appropriate companies under each one but I could not figure out how to use those in a filter. In short I need to group companies together so the groups can be chosen from a dropdown filter.
I was able to find the answer to my question from another site. I wanted to share.
I had to use the locate function to create my groups in a calculated field.
Syntax for Calculated field:
locate(expression, substring, start)
Looked something like this:
ifelse
(
locate('Hotel by Marriott',{Hotel Name}) > 0,
'Marriott',
locate('Homewood Suites Hotel A, Homewood Suites Hotel B ',{Hotel Name}) > 0,
'Homewood Suites',
locate('Home 2 Suites Hotel A,Home2 Suites Hotel B',{Hotel Name}) > 0,
'Home2 Suites',
'Other Brands'
)
Expression is the actual Name in the specific field called Hotel Name list all values for that group in single quotes separated by commas.
Substring is the Field reference (Hotel Name)
Start is the Group Name ('Marriott') you want to refer to it by.
Then create a parameter as String with Multiple Values. Save and create a control with Multiple Static values which is your list of Group Names as written in the calculated field.

Querying Elasticsearch using array of values

I index items in elasticsearch where in each item has these properties:
tags - array of strings eg. [ 'c++', 'java', 'python' ]
submitter_id - uuid
id - uuid
Also i have user who has these properties:
tags - array of strings
following_ids - array of uuids
What i want to do is query elasticsearch for items where tags match tags of the user or submitter_id is one of user's following_ids, also i boost fields. Right now i form the query like this
"should"=>[{"match"=>{"tags"=>{"query"=>"yoga", "boost"=>3}}}, {"match"=>{"tags"=>{"query"=>"yogic technique", "boost"=>3}}},
{"match"=>{"tags"=>{"query"=>"lag jaa gale", "boost"=>3}}}, {"match"=>{"tags"=>{"query"=>"jonita gandhiband", "boost"=>3}}}
{"match"=>{"submitter_id"=>"fc8b720f-a306-4849-8bc1-38fafae7c92b"}},
{"match"=>{"submitter_id"=>"c35ec42f-2df0-4870-89a4-9e59c9df04ea"}}]
But if the user has a lot of tags or following_ids, i would soon run into maximum clauses limit. How should i handle this ?
Since you're looking for the exact ids and tags you should be using the Terms Query anyway but the added advantage for you in this case is that it allows you to give multiple terms so you would only need 1 clause for all your tags and 1 for your user ids.

geopoint query secondary sort by date

I am querying for objects by a geopoint field : location -
var query = new Parse.Query("pointOfinterest");
query.withinKilometers("location", userLocation, searchRadius);
I want the primary sorting order to be by distance and secondary by creation date.In other words - I'd like results from the same distance to be ordered by date ( descending - newest first )
so I tried adding :
query.ascending("location");
query.addDescending("createdAt");
or just:
query.descending("createdAt");
or :
query.addDescending("createdAt");
doesn't work - when I add the createdAt , the location order gets messed up
From Parse.com developer guide:
Note that if an additional orderByAscending()/orderByDescending()
constraint is applied, it will take precedence over the distance
ordering.
See this link.
So, I think you should get the array first and order it on createdAt yourself.
Also, the order is ascending by distance on default, so no need to order on distance in your query.

Change Group Labels in AdvancedDataGrid

I'm trying to use an AdvancedDataGrid to display some grouped data. Normally flex displays this in a "tree view" with a folder icon represent the group. I need to group the data based on an integer ID field in my object, but I'd like the label for the folder icon to display the groupName field in my object.
Here's a little example:
{groupName: group1, ID: 1234}
{groupName: group2, ID: 5678}
<mx:grouping>
<mx:Grouping label="Group"> <--- The label of the whole column
<mx:GroupingField name="ID">
</mx:Grouping>
</mx:grouping>
Resulting output:
=== Group ===
+ 1234
- child
- child
+ 5678
...
But I'd really like to output:
=== Group ===
+ group1
- child
- child
+ group2
...
If anyone has any tips I'd appreciate it.
-- Dan
Have a look at GroupingField#groupingFunction. From the adobe docs:
A function that determines the label for this group. By default, the group displays the text for the field in the data that matches the filed specified by the name property. However, sometimes you want to group the items based on more than one field in the data, or group based on something that is not a simple String field. In such a case, you specify a callback function by using the groupingFunction property.
private function myGroupingFunction(value:Object, field:GroupingField):String

Resources