The constructor of PHPExcel_Chart_DataSeriesValues is:
construct (
$dataType = self::DATASERIES_TYPE_NUMBER,
$dataSource = null,
$formatCode = null,
$pointCount = 0,
$dataValues = array(),
$marker = null
)
I try to insert formatCode in this way:
$xAxisTickValues = array(
new PHPExcel_Chart_DataSeriesValues('String', 'worksheet!$A$2:$A$9', 'yyyy-mm-dd hh:mm:ss', NULL, 4));
but it does not work? what is wrong here?
I use PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART.
When I not use 'formatCode' my x-axis shows raw excel datetimes: 41760,41761..,and so on?instead of 2014-05-01 00:00:00,2014-05-01 12:00:00,..,
Does anyone have an good example on how to insert date and time on the x-axis in PHPExcel?
I found a solution by making a hack in PHPExcel/Writer/Excel2007/Chart.php line 493
//$objWriter->writeAttribute('formatCode', "General");
$objWriter->writeAttribute('formatCode', "dd/mm/yy\ hh:mm:ss;#");
Change the formatCode to "dd/mm/yy\ hh:mm:ss;#"
but why is "General" hard-coded !?
UPDATE:
Found another bug in PHPExcel/Writer/Excel2007/Chart.php
Change $id2 to $id1. If you do not want problems with the y-axis label positioning?
if ($id1 > 0) {
$objWriter->startElement('c:crossAx');
//$objWriter->writeAttribute('val', $id2);
$objWriter->writeAttribute('val', $id1);
$objWriter->endElement();
Related
I'm running a tdload command using a job variables file with values :
SelectStmt = 'select * from database.tablename where column1 > 100',
SourceTdpid = 'hostid',
SourceUserName = 'username',
SourceUserPassword = 'password'
SourceTable = 'database.tablename',
FileWriterFileSizeMax = '10M',
TargetTextDelimiter = '|'
TargetFilename = "file.csv"
FileWriterQuotedData = "Y"
The filter clause in the select statement should return me only 39 rows,
but I'm getting all of the rows from the table in the extracted file.
How to resolve this?
Had to use ExportSelectStmt instead of SelectStmt
Okay so I have a table like shown...
I want to use PowerBI to create a new column called 'First_Interaction' where it will say 'True' if this was the user's earliest entry for that day. Any entry that came in after the first entry will be set to "False".
This is what I want the column to be like...
Use the following DAX formula to create a column:
First_Interaction =
VAR __userName = 'Table'[UserName]
VAR __minDate = CALCULATE( MIN( 'Table'[Datetime] ), FILTER( 'Table', 'Table'[UserName] = __userName ) )
Return IF( 'Table'[Datetime] = __minDate, "TRUE", "FALSE" )
Power BI dosnt support less than second so your DateTime Column must be a Text value. Take that on consideration for future transformation.
I'm trying to figure out how I can change the format of the Date value inside a node once I get the data. The code below fetches each specific value inside the node
foreach ($degreePrograms as $key => $program) {
$programNode = _nodeLoad($program);
$variables['degree_programs'][$key]['title'] = $programNode->get('title')->value;
$variables['degree_programs'][$key]['body'] = $programNode->get('body')->value;
$variables['degree_programs'][$key]['date'] = $programNode->get('field_start_date')->value;
$variables['degree_programs'][$key]['link'] = $programNode->toUrl();
}
This code fetches the Date value inside the node and returns with a numbered date form 2017-09-04. How can convert it to March 04, 2017 instead
$variables['degree_programs'][$key]['date'] = $programNode->get('field_start_date')->value;
Try this one
$timestamp = strtotime($programNode->get('field_start_date')->value);
$new_date_format = date('F j, Y', $timestamp);
I know that NULLIF(X,Y) function of SQLITE work equivalent to:
CASE
WHEN
X = Y
THEN
NULL
ELSE
X
END
and IFNULL(X,Y) function work equivalent to:
CASE
WHEN
X IS NULL
THEN
Y
ELSE
X
END
IFNULL(X,Y) function of SQLITE is used for replacing the NULL values of X to the Y but I can't understand the use of NULLIF(X,Y) function of SQLITE.
Please explain with examples, so it is more useful.
The IFNULL function is used when the database contains NULL values, but you want to handle those values as something else; for example:
SELECT Name, IFNULL(Age, 'unknown') AS Age FROM People
The NULLIF function is used when the database contains special values that are not NULL, but that you want to handle as NULL.
This is useful especially for aggregate functions. For example, to get the number of employees that get bonuses, use:
SELECT COUNT(NULLIF(Bonus, 0)) FROM Employees
This is the same as:
SELECT COUNT(*) FROM Employees WHERE Bonus != 0
In practice, NULLIF is not used as often as IFNULL.
I use NULLIF() when UPDATing or INSERTing rows containing NULLable fieds.
Basically with PHP :
$value1 = 'foo';
$value2 = '';
$sql = 'INSERT INTO table(field1, field2) '
. "VALUES(NULLIF('$value1', ''), NULLIF('$value2', ''))";
// => INSERT INTO table(field1, field2) VALUES(NULLIF('foo', ''), NULLIF('', ''))
// => INSERT INTO table(field1, field2) VALUES('foo', NULL)
It saves me doing things like :
$value1forSQL = ($value1 === '' || $value1 === NULL) ? 'NULL' : "'$value1'";
...
$sql = ...
. "VALUES($value1forSQL, ...)";
I'm trying to alter a query in a view using mymodule_views_pre_execute and have used devel to find the sql query it is currently using, which is below:
SELECT node.nid AS nid FROM node node LEFT JOIN field_data_field_date
field_data_field_date ON node.nid = field_data_field_date.entity_id AND
(field_data_field_date.entity_type = :views_join_condition_0 AND
field_data_field_date.deleted = :views_join_condition_1)
WHERE ((
(DATE_FORMAT(field_data_field_date.field_date_value, '%Y-%m-%d\T%H:%i') > :node_date_filter) )AND
(( (node.status = :db_condition_placeholder_2) )))
LIMIT 10 OFFSET 0
I am then re-doing this using the following:
$query = db_select("node", "n");
$query->addField("n", "nid");
$query->leftJoin("{field_data_field_date}", "{field_data_field_date}",
"n.nid = field_data_field_date.entity_id AND field_data_field_date.entity_type = 'node'
AND field_data_field_date.deleted = '0'");
$query->where("(DATE_FORMAT(field_data_field_date.field_date_value, '%Y-%m-%d\T%H:%i') > NOW())");
$query->where("n.status = '1'");
I've had to replace :views_join_condition_0 with 'node', :views_join_condition_1 with '0' and :node_date_filter to NOW() although i'm not sure if this is the correct way? If I leave :views_join_condition_0, :views_join_condition_1 and :node_date_filter in though it doesn't work?!
Use hook_view_query_alter(&$view, &$query) instead.