Multiple value conversions in one field in Access 2016 - type-conversion

I have a database of NYC real estate properties that utilizes the BBL (Borough, Block, Lot) system.
The format of the first table is 1/9999/9999999, where the first number is the borough, the second series of numbers is the block, and the third series of numbers is the lot. In this format, in the first number of the series, 1 is Manhattan, 2 is Bronx, 3 is Brooklyn, 4 is Queens, and 5 is Staten Island.
The format of the second table is text, as follows:
Borough Block Lot
MANHATTAN 0033 1085971
MANHATTAN 0033 1085971
MANHATTAN 0033 1064871
MANHATTAN 0033 1030178
How can I convert five different Borough values into five different integer values in the same field so that I can create a relationship between the two tables based on a common BBL field? I would rather not do a nested IIF function.

You can use Left to extract the borough id from the BBL code, then Choose to select the name:
Borough: Choose(Left([BBL], 1), "Manhattan", "Bronx", "Brooklyn", "Queens", "Staten Island")

Related

Tableau How to evenly split a Ranking Table into two

I am trying to evenly split a ranking table into two.
I tried to create a calculated field using rank to divide the data into two groups.
The problem with this approach is that there are too many entries in the first column because they are tie with rank 1.
I don't want to break the tie but display evenly in both columns.
So, desired output will look like...
25 states with Rank 1 are displayed in column 1, and the rest 12 rank 1 states and the other states from rank 38 to 49 are displayed in column 2.
In order to split your rows within a specif number (say 25) you can't rely just on rank due to same values for multiple rows.
Even though your Rank calculated field must be shown in the chart, you can add another calculated field based on rank_unique which will provide you a progressive number for rows having the same value for the specified metric.
Just use the specified function:
RANK_UNIQUE(SUM([Value]),'desc')
And then use the calculated field as a filter to "split" the results as you need (in this example 1-4, 5-8).

combine two columns and create one in ADF

as a step to create my dimensional data model I need to combine two columns and create one new referencing to the units of values from each columns.
I have among other tables one table that has yearly GDP of a country. the table has two columns GDP represented as MONEY (unit) and the other year change (% as unit). in my fact table I would like to have both in same column but with a new columns representing dimension (units). because of that I am wondering how to merge these two columns and create another one that would specify if the value comes from the column with units (%) or (money). this applies to other entities in the data model that can have different units for same variable.
thanks for your help!
Consider orginal data format :
enter image description here
We have quartal dates a series of economic indicator and their values, on the right side there is another table with dimensions of the economic indicator.
What I need is to change data so it should be like this (fact table with quartal date granularity) :
enter image description here
I have reproduced the above scenario with a sample data and able to combine the columns like below.
My sample data of two columns Money and Unit:
Use derived column transformation for the res column which will have the Unit or Money values. To know which column value, I have used another column which_value.
Expression for res column:
iif(isNull(Money),Unit,Money)
Expression for which_value column:
iif(isNull(Money), 'Unit', 'Money')
Result in Data preview:

Creating Dual Axis with "long" data

I am new to Tableau. I have a dataset made up of year, has a measure that can be one of many values, and a corresponding value for that measure. Example:
YEAR MEASURE Value
1988 Number of Cars 10
1989 Number of Cars 15
1988 Number of Peds 5
1989 Number of Peds 6
This is just an example data set. But, I want to create bar char for Number of Cars and a line graph for Number of Peds. How can this be done? I was told I can do this without reorganizing the dataset (into a wide data set).
thanks
jason
You can create two calculated fields to separate Cars from Peds counts as follows:
if [measure name] = 'cars' then value end
Repeat for Peds. Then follow these instructions for dual axis.
https://onlinehelp.tableau.com/current/pro/desktop/en-us/multiplemeasures_dualaxes.html

The most effective way to use interp1 command in matlab with two columns

I have two columns (same size) that I have to interpolate in Matlab. First column is a vector of time in hours (9.5, 9.6 9.73 10.13 etc...) and the other column are stock prices associated to each element of the column "time in hours".
I wish to have some prices that are associated with each 15min, 30min, 45min, and 1hour (60min) that are missing in my price vector. And therefore, thee elements (15,30,45min and 60min) are also missing in my column of time per hours.
How can I linearly interpolate two columns in order to have the same size and then be able to associate a price at every 15min (X.25hour, X.5hour, X.75hour and X hour)?
Thank you!
It's a one line command:
interp_prices = interp1(time, prices, 0:0.25:max(time));

Plotting time-series in Matlab with "label grouping"

In Matlab, I have data in the following form:
"z", a 17'256x1 double, containing the residuals of a regression, e.g. -0.0596
"dates", a 17'256x1 cell, containing date- and timestamps of each observation in the regression (and therefore, of the residuals), e.g. '10/3/2011 9:30:00 PM'
What I would like to do:
Plot the residuals versus the datestamp as label. The observations are not from a continuous sequence of days (i.e. there might be some gaps with no observations between days), and some days have more observations than others. I cannot have one label per observation because that would be too many labels. So I need to group them somehow, either by day or by month. That is, only show the month and day (e.g. 10/3) under all the observations from that day, or only show the month (e.g. 3) under all the observations from that month. How can I do that, using the data I have?
You should be able to plot this without 'grouping' things. If you convert your dates to timestamps:
timestamps = cellfun(#(date)datenum(date), dates);
then you can do a normal plot:
plot(timestamps, z);
and Matlab will deal with the xaxis labels itself (i.e. it will spread them evenly over the time range of dates), but they will be the timestamp numbers. To get formatted dates on the xaxis, use:
datetick('x');