I would like to create new column in my transformation
From JSON I receive let's say two colums (instrument, price) but the price is in integer value (for example: 1.24124 -> 124124). From the table input I get instrument and decimal places, so I would like to create column that take price (from Json input) and divide it by 10^(decimal) (from Table input). I do not know how to do it.
Related
I have linked a Big Query Project to my Google Ads Account. Within that, we have a campaignBasicStats table.
I want to pull the cost of a campaign from my Google Ads account into a big query workspace to apply some additional logic.
The cost column is coming through as an INTEGER and is described like this:
INTEGER NULLABLE
The sum of your cost-per-click (CPC) and cost-per-thousand impressions (CPM) costs during this period. Values can be one of: a) a money amount in micros, b) "auto: x" or "auto" if this field is a bid and AdWords is automatically setting the bid via the chosen bidding strategy, or c) "--" if this field is a bid and no bid applies to the row.
If I query the table, the cost returns in this value: Example:
2590000.0
965145.0
In Google Ads, the two costs for these campaigns are £25.90 and £96.51
So I have this code in my Big Query Workspace.
SELECT CAST(Cost AS FLOAT64)
FROM `db_table`
WHERE COST > 0
LIMIT 1000
The column returns these numbers:
2590000.0
965145.0
However, As I need the numbers to be a currency for example the first return 2590000.0 should be 25.90 and the second one should be 96.51
I changed my code to this:
SELECT CAST(Cost AS FLOAT64(4,2))
FROM `db_table`
WHERE COST > 0
LIMIT 1000
And now I get this error:
FLOAT64 does not support type parameters at [1:28]
Is there something I'm missing? how do I convert to decimal point and specify where I want the decimal point to be in BQ?
Thanks,
It appears you are using a Google Ads Data Transfer operation as detailed here.
In this case, it's important to note the Description of the Cost column in p_CampaignBasicStats:
The sum of your cost-per-click (CPC) and cost-per-thousand impressions
(CPM) costs during this period. Values can be one of: a) a money
amount in micros, b) "auto: x" or "auto" if this field is a bid and
AdWords is automatically setting the bid via the chosen bidding
strategy, or c) "--" if this field is a bid and no bid applies to the
row.
1 micro is 1-millionth of the fundamental currency. Thus, we need to transform this amount as such: cost / 1000000
Then, we simply need to ROUND to get the appropriate unit. If you prefer to always round up, see my answer regarding the correct way to do that here.
First, we'll set up an example table with the example values you've given:
CREATE TEMP TABLE ex_db_table ( Cost INTEGER );
INSERT INTO
ex_db_table
VALUES
( 2590000 );
INSERT INTO
ex_db_table
VALUES
( 965145 );
Then we'll select the data in your preferred unit:
SELECT
ROUND(Cost / 1000000, 2) as currency_cost
FROM
ex_db_table;
Of note, your math in your question is incorrect here as the actual values of your Cost examples equate to 2.59 and 0.97.
Am a newbie in Microsoft Access 2016 making a database system for processing loans.
I have made two fields:
ID e.g: 001 with datatype number and
NRC (This is the official National Registration Card number in my country e.g: "123456/78/1" )
I now want to generate a new field:
LoanNumber from the fields 1. ID and 2. NRC mentioned above.
From the examples above, I want this new field to be composed with two parts concatenated together; that is "ID-first part of NRC before the first '/' ".
e.g: LoanNumber : 001-123456
What code in the expression builder will will help me achieve this?
A number datatype value cannot be saved with preceding zeros. Use Format function to manipulate number. This can be done in a query or textbox but not in table because Format function is not available for Calculated field type.
Format([ID], "000-") & Left([NRC], 6)
i have this kind of data
-
B-3-I11
B-3-I12
BI1-I190
BI1-I191
BI1-I192L
BI1-I194A
BI1-I195L
BI1-I198R
BI1-I199L
BI1-I200Ac
BI1-I201L
conasde
Installation
Madqw
Medsfg
Woasd
this is the data I have .. now I want only those which start from B and have some numeric character in data..how I get in qlikview script
how to extract only those data ..
To filter to those that start with B you'd do
where left(Field,1)=B
Then to filter on those with numbers, you could add
and len(keepchar(Field,'1234567890'))>0
So that would give something like this:
LOAD Field
From Table
Where left(Field,1)=B
AND len(keepchar(Field,'1234567890'))>0
(where Field is the name of the field your data is in and Table is the name of the table your data is in)
Or, if you want to keep all the data but create a new field you would do:
LOAD
Field,
if(left(Field,1)=B AND len(keepchar(Field,'1234567890'))>0`,Field) as FieldFiltered
From Table
I could use some help in inventorying some online purchases.
I would like the information in column A to be separated into the following:
Vendor name; item description; eBay item #; purchase price; shipping cost; purchase date
example:
ldean747; MEN'S WILLIAM BAY" "; 260725743398; 10.50; 0.00; 01/28/11
I'm getting hung up because some of the products do not have shipping cost (which would be the second dollar amount you see in the picture).
Any easy way to do this rather than going through and copy paste, transpose on each purchase?
You have a couple of challenges here
dynamic data set format: 3 text fields followed by 1 or 2 numeric fields (vertically)
multiple field seperators / delimiters across your data set
1st field: '()''
2nd field: '|'
3rd field: ':'
You could now start to create formulas which extract the relevant parts of each field using functions like =LEFT(), =MID(), =RIGHT(), =SEARCH(), etc. which for some cases (3rd field) is pretty straightforward, for others can get a bit complex ...
Concretely - the fields can be identified as following:
if the cell above is numeric AND I am alpha THEN I am 1st field
if the cell above is 1st field THEN I am 2nd field
if the cell above is 2nd field THEN I am 3rd field
if the cell above is 3rd field THEN I am product cost
if the cell above is numeric AND I am numeric THEN I am shipping cost
numeric / alpha: =TYPE(), extracting substrings seperated by seperation characters is well covered here at SO
Alternatively you could start to write a VBA program that does the same job for you
meta code:
loop through all rows
determine record type
process record type
So give it a try and come back with more questions.
I feel stupid asking this, but I really need an excample on how to get a value of a field in one table (in the end in my report) depending on a value of a field from an other table in Access.
So I have (for excample) a table:
Products and in my report I do a formule using the value of price (field of Products) and adding to that I must have the value of the field VAT-Type (a nummeric var, in the table VATS) depending on what is there in the record (of the one in the table Products) in the field VAT-Sort, also a nummeric var that must meet one of the values used in the field VAT-Type).
So in the report I must have something like:
Product: X Count Price'=(price+21%)'
where 21% comes from the dependensy between the field VAT-Type and VAT-Sort.
I know I can do something like result=select 'VAT-Sort' from 'VATS' WHERE 'VAT-Sort' = or equals 'VAT-type'
But how do I use it in a report of Access to get the right result?
You can use DLookUp:
Numeric data type:
DlookUp("Value","Vats","Vat_Type=" & Vat_Sort)
Text data type:
DlookUp("Value","Vats","Vat_Type='" & Vat_Sort & "'")
Or you can base your report on a query, say:
SELECT Value, Other, Field, names FROM Products
LEFT JOIN Vats
ON Products.VAT_Sort = Vats.Vat_Type
Edit re comments