In Quicksight is it possible to define values in an array from a split function as dimensions? - amazon-quicksight

I have a field subspecialty that can contain multiple values as a string separated by commas.
I am trying to get the sum of another field ('topic_ids) grouped by the values in subspecialty`. In other words... number of topics completed grouped by subspecialty, but there are multiple subspecialties listed in the field in each row.
So far I've managed to use split to separate subspecialty values into different fields.
There are up to five values in the field at once, so I created 5 different custom fields.
split({subspecialty[flattened_content]},',',1)
split({subspecialty[flattened_content]},',',2)
split({subspecialty[flattened_content]},',',3)
split({subspecialty[flattened_content]},',',4)
split({subspecialty[flattened_content]},',',5)
so something like subspecialty[flattened_content] = {Neuro, Emergency, Head and Neck, Vascular, Physics}
becomes
subspecialty_split_1 = "Neuro"
subspecialty_split_2 = "Emergency"
subspecialty_split_3 = "Head and Neck"
subspecialty_split_4 = "Vascular"
subspecialty_split_5 = "Physics"
with these fields split, I can now create additional custom fields to count topic_id where any one of subspecialty_split_n fields = a particular value.
countIf
(
{topic_id},
{subspecialty_split_1} = "Neuro"
OR
{subspecialty_split_2} = " Neuro".
OR
{subspecialty_split_3} = " Neuro"
OR
{subspecialty_split_4} = " Neuro"
OR
{subspecialty_split_5} = " Neuro"
)
This has at least allowed me to create a table that counts topic ID by individual subspecialties, but because they are custom aggregations, I can't do anything like sorting, using charts, etc.

Related

New Column or Measure for NAICS ID based on first two numbers

Use first two digits of Column to give a name to a new column.
I have a list of companies and their NAICS ID. I would like to filter these into a pie chart but I don't want the 90000 different names (just the general ex. Agriculture or Mining). I want to utilize the first two digits in for the column to identify its general name. I am trying to use the DAX expression Switch to get this started. Is there a filter to do this within PowerBI?
I haven't started yet since I am not sure if this is possible.
You could simply create a calculated column based off of the original NAICS code using the following:
FirstTwoDigitsOfNAICS :=
SWITCH (
TRUE (),
LEFT ( 'Table'[NAICSCode] ) = x, "Something",
LEFT ( 'Table'[NAICSCode] ) = y, "Something Else"
)
This DAX will simply pull the first two characters from the entire code.

How to split a Webix datatable column into multiple columns?

In my webix datatable, I am showing multiple values in the cells for some columns.
To identify which values belong to which header, I have separated the column headers by a '|' (pipe) and similarly the values under them as well.
Now, in place of delimiting the columns by '|' , I need to split the columns into some editable columns with the same name.
Please refer to this snippet : https://webix.com/snippet/8ce1148e
In this above snippet, for example the Scores column will be split into two more editable columns as Rank and Vote. Similarly for Place column into Type and Name.
How the values of the first array elements is shown under each of them will remain as is.
How can this be done ?
Thanks
While creating the column configuration for webix, you can provide array to the header field for the first column along with the colspan like below:
var columns = [];
columns[0] =
{"id":"From", "header":[{"text":"Date","colspan":2},{"text":"From"}]};
columns[1] =
{"id":"To","header":[null, {"text":"To"}]};
column[0] will create Date and From and column[1] will be creating the To.

Swift/Firebase sorting

I am currently experiencing some issues regarding table view sorting from firebase. What I am trying to achieve is to list 5 different price tiers in a table view, all named (tier1, tier5, tier12, tier24, tierPermanent) - each containing a value (the price).
However, while fetching these values from the database, I find it rather difficult to show these in a table view - both containing text (the time) and the price tiers. What I am doing now, is that I am using observeEventType to display all the values, and then store each value in a dictionary. After that I append it to an array of dictionaries of type [[String:String]].
What I am struggling with, is to display this in a descending order in a table view. Please take note that all of these 5 values are optional, and therefore they might not contain any value - so instead of showing a value on the very first row, and a blank cell at the second, and then a new value on the third row - I want it to display descending compared to the values. (The permanent value will always be on top if it contains a value, or else tier24 will be on top, or else tier12.). For each cell.
I know I would access the unique value with cell.nameLabel.text = cell[indexPath.row]["tier.."] as? String - but the problem is that I need to have some sort of ordering, and make sure the data isn't displayed twice. (order with both key and value - to display both key and value in the same cell.).
Any ideas on how I would approach this?
Thanks in advance.
There's really not enough data to fully address the question but how about this:
A Firebase structure:
tiers
-Y0998uas9j
tier_type: tier_24
time: 20160705130100
sort_order: 1
-Ykja9s9js9
tier_type: tier_05
time: 20160705130300
sort_order: 3
-Yukl9jh8sj
tier_type: tier_permanent
time: 20160705130500
sort_order: 0
tiers have a sort order to keep them in the correct order.
tier_permanent = 0
tier_24 = 1
tier_12 = 2
tier_05 = 3
tier_01 = 4
and some code to read them in and keep the sorted, descending:
var myArray = [[String:String]]()
let tiersRef = self.myRootRef.child("tiers")
tiersRef.observeSingleEventOfType(.Value, withBlock: { snapshot in
for child in snapshot.children {
var dict = [String: String]()
dict["fbKey"] = child.key as String
dict["tier_type"] = child.value["tier_type"] as? String
dict["timestam"] = child.value["time"] as? String
dict["sort_order"] = child.value["sort_order"] as? String
myArray.append(dict)
}
myArray.sortInPlace( {$0["sort_order"] < $1["sort_order"]} )
self.mySuperTableView.reloadData()
for dict in myArray { //meh, print them so show they are sorted
print(dict)
}
})
This addresses: keeping them sorted, descending, and if the tires are not present in the database, they will obviously not be read in.
The issue is though, it's unclear from he question the correlation between the tier names and the value (time?). I'll update once more information has been presented.

How do I split birt dataset column into multiple rows

My datasource has a column that contains a comma-separated list of numbers.
I want to create a dataset that takes those numbers and turns them into groupings to use in a bar chart.
requirements
numbers will be between 0-17 inclusive
groupings: 0-2,3-5,6-10,11-17
x-axis labels have to be the groupings
y-axis is the percent of rows that contain that grouping
note that because each row can contribute to multiple columns the percentages can add up to > 100%
any help you can offer would be awesome... i'm very new to BIRT and have been stuck on this for a couple days now
Not sure that I understand the requirements exactly, but your basic question "split dataset column into multiple rows" can be solved either using a scripted dataset or with pure SQL (depending on your DB).
Either way, you will need a second dataset (e.g. your data model is master-detail, and in your layout you will need something like
Table/List "Master bound to master DS
Table/List "Detail" bound to detail DS
The detail DS need the comma-separated result column from the master DS as an input parameter of type "String".
Doing this with a scripted dataset is quite easy IFF you understand Javascript AND you understand how scripted datasets work: Create a report variable "myValues" of type object with a default value of null and a second report variable "myValuesIndex" of type integer with a default value of 0.
(Note: this is all untested!)
Create the dataset "detail" as a scripted DS, with one input parameter "csv" of type String and one output parameter "value" of type String.
In the open event of the scripted DS, code:
vars["myValues"] = this.getInputParameterValue("csv").split(",");
vars["myValuesIndex"] = 0;
In the fetch event, code:
var i = vars["myValuesIndex"];
var len = vars["myValues"].length;
if (i < len) {
row["value"] = vars["myValues"][i];
vars["myValuesIndex"] = i+1;
return true;
} else {
return false;
}
For example, for the master DS result row with csv = "1,2,3-4,foo", the detail DS will result in 4 rows with
value = "1"
value = "2"
value = "3-4"
value = "foo"
Using an Oracle DB, this can be done without Javascript. The detail DS (with the same input parameter as above) would then look like:
select t.value as value from table(split(?)) t
For the definition of the split function, see RedFilter's answer on
Is there a function to split a string in PL/SQL?
If you get ORA-22813, you should change the original definition
create or replace type split_tbl as table of varchar2(32767);
to
create or replace type split_tbl as table of varchar2(4000);
as mentioned on https://community.oracle.com/thread/2288603?tstart=0
It's also possible with pure SQL in 11g using regexp_substr (see the same page).
create parameters in the scripted data set. we have to pass or link actual dataset values to scripted dataset parameters through DataSet parameter Binding after assigning the scripted data set to Table.

django-queryset: query many columns at once

I have a django app (w/postgresql database) that stores information on nest conditions for an endangered bird. Data is collected over multiple sites with different #'s of nests at each site. The nest conditions also have a unique date range per site.
DB Columns: site_name, date, nest_01, nest_02, nest_03 ... all the way to nest_1350.
The nests have values of either empty, 1E, 2E, 3E, or 4E.
Is there a way to do 1 query of all (1-1350) of the nest columns looking for '1E'?
Thanks
Do you actually have a model with 1350+ columns?
If I were you I'd normalize the whole setup like this:
class Site(Model):
site_name = Charfield()
date = DateField()
class Nest(Model):
name = Charfield()
condition = Charfield()
site = ForeignKey(Site)
And then query it like this:
site = Site.objects.get(pk=1) # just a Site, I assume you know a Site
nests = Nest.objects.filter(site=site).filter(condition='1E') # your desired nests

Resources