Where do I set the data format when displaying data from a dataTable? The code below is not working.
a.getDataTable().getValue(0, 2, {pattern: "dd-MM-yyy"})
first, you must format the data table values.
you can use one of Google's formatters, in this case the DateFormat class.
once the data table has been loaded with data,
use the formatter to format the data.
// create date formatter
var formatDate = new google.visualization.DateFormat({
pattern: 'dd-MM-yyyy'
});
// format data table column index 2
formatDate.format(dataTable, 2);
then when displaying data from the data table,
use the getFormattedValue method, to display the formatted value...
dataTable.getFormattedValue(0, 2);
Related
I got bellow query table, now i need one more column that would show all the latest value of unit id which is the true value of the Custom and currentUnit column
data table image
expected result would be in the image
expected result image
Any help please!
Copy currentUnit to New
Replace false with null
Transform - Fill up
Replace value with null where custom = True
Provide sample data in copyable format if you need more detailed instructions
I have a custom log format where the log entries vary by the request type. So certain rows have more fields.
Can we specify certain fields as optional so that in rows that they are missing, the values will be set to certain default (null, 0)?
Here are some hypothetical log entries:
{"data":"[2017-09-10 10:44:54.448998 -0000] info ip=773.555.557.445 cluster=\"production\" query=uris type=TXT class=IN rcode=NXDOMAIN cnt=0 offset=74","header":{"recvtime":"2017-09-10 10:45:02","server":"m0107481","refid":"ABC-123"}}
{"data":"[2017-09-10 10:44:54.457718 -0000] info ip=991.509.704.832 cluster=\"inbound\" query=dnsbl type=A class=IN rcode=NOERROR cnt=1 offset=90 score=400","header":{"recvtime":"2017-09-10 10:45:02","server":"m010748","refid":"ABC-123"}}
{"data":"[2017-09-10 10:44:54.457718 -0000] info ip=971.509.704.832 cluster=\"inbound\" query=dnsbl type=A class=IN rcode=REFUSED cnt=1","header":{"recvtime":"2017-09-10 10:45:02","server":"m010574","refid":"ABC-123"}}
Note that each row of the log data is in json format, and the header part is fixed. If query in data is dnsbl, then sometimes the row has a score field, but other times it is missing. And I am planning to use Athena to parse this type of data from S3 and query for some stats in the line of: what % of data are dns queries and what % have score above 300.
It looks like your data is JSON with embedded structured logging in the data field. As long as the data is well formed JSON with one object per line you should be able to create a JSON table and then use functions to extract the other pieces out of the data field. You can create a view that does the extraction so that you don't have to do that in every query.
I'm thinking something like this:
CREATE EXTERNAL TABLE raw_log_entries (
data string,
header struct<recvtime: string, server: string, refid: string>
)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
LOCATION 's3://some-bucket/and/path/';
CREATE VIEW log_entries AS
SELECT
header.recvtime,
header.server,
header.refid,
regexp_extract(data, 'query=(\S+)', 1) AS query,
regexp_extract(data, 'type=(\S+)', 1) AS type,
regexp_extract(data, 'score=(\S+)', 1) AS score,
-- and so on
FROM raw_log_entries
You'll have to experiment with the regexes, since I don't have your data I can't be sure if they will work for all cases, but I hope you get the idea.
I have a issue in Oracle Apex Data Load which I will try to explain in a simple way:
I want to copy csv data (copy/paste) in Data Load Application and apply the transformation, and rules and load the data into the table BIKE.
csv columns (type, amount-a, amount-b)
blue, 10, 100
green, 20, 200
table BIKE columns
(type, amount)
I want to create a transformation to check if the column value in the table BIKE is 'blue' then load amount-b other wise amount-a.
Can anyone help me on this?
Thanks
Create a staging table, e.g. like this (you will need to adjust the details of the columns to match your data model):
create table bike_staging
(
apex_session number not null,
bike_id number not null,
bike_type varchar2(100) not null,
amount_a number,
amount_b number
);
Add a trigger to populate session_id:
create or replace trigger bi_bike_staging
before insert on bike_staging for each row
begin
:new.apex_session := v('APP_SESSION');
end bi_bike_staging;
Add two processes to the third page of the data load wizard, on either side of the "Prepare Uploaded Data" process, like this:
The code for "delete staging table" will be like this:
delete bike_staging where apex_session = :APP_SESSION;
The code for "load bikes" may be something like this:
merge into bikes t
using (select bike_id,
bike_type,
case bike_type
when 'BLUE' then amount_b
else amount_a
end as amount
from bike_staging
where apex_session = :APP_SESSION
) s
on (t.bike_id = s.bike_id)
when matched then update set
t.bike_type = s.bike_type,
t.amount = s.amount
when not matched then insert (bike_id, bike_type, amount)
values (s.bike_id, s.bike_type, s.amount);
delete bike_staging where apex_session = :APP_SESSION;
Alternatively, if you are only inserting new records you don't need the merge, you can use a simple insert statement.
I have a table that contains the entire history of the actions which are performed on the system by the users. I need to retrieve all those records in date descending order. The problem is I have saved the date in string format in my table, since my application support multi-culture. I don't know it was a good idea or bad, now I need to retrieve them in date descending order. So, when I am retrieving the data I am trying to convert the date to DateTime format, but I am getting an exception to invalid date format. In my database, the date is in dd-MM-yyyy format. Following is my query:
db.Histories.ToList.OrderByDescending(x=> Convert.ToDateTime(x.Date));
It seems your data is not all of valid datetime format's.
You must cleen up the data first, I think.
Or you could sort like this:
var tmp = array.OrderByDescending(x => ParseDate(x.DateTest));
private static DateTime ParseDate(string dateString)
{
var dateFormats = new[]
{"dd-MM-yyyy", "dd/MM/yyyy", "M/d/yyyy", "d.M.yyyy", "dd.MM.yyyy", "MM/dd/yyyy", "M/d/yyyy"};
try
{
return DateTime.ParseExact(dateString, dateFormats, CultureInfo.CurrentCulture,
DateTimeStyles.None);
}
catch (Exception ex)
{
return DateTime.Now.AddYears(-500);
}
}
Where the not valid datetime strings will end up last in the sorted list.
I have a date item ' Order_TCD' in the form.
My requirement is when user enters Order_TCD it should be in the format:
DD-MON-YYYY HH:MIPM,
But the data in the report should appear in the format DD-MON-YY.
DD-MON-YYYY HH:MIPM
If Order_TCD is DATE data type, then while inserting the row you need to use TO_DATE and required format mask. You must specify the user to enter the date in the format DD-MON-YYYY HH:MIPM. And you need to handle it as:
TO_DATE('05-MAY-2015 11:05AM','DD-MON-YYYY HH:MIPM')
But the data in the report should appear in the format DD-MON-YY.
To display the date in your desired format, you need to use TO_CHAR.
For example,
TO_CHAR(Order_TCD, 'DD-MON-YY')
To set the format mask on the (datepicker!) item, simply edit the item and go to the "Settings" section. You can enter the format mask there.
To display with another format mask in the report, you can set the format mask in the column attributes. Example here for an interactive report.
You could also apply the mask on the column in the source SQL of course. Also note that you can set a global application date format mask in the globalization options of the application.