BIRT Two dataset and two tables (inner/outer) - Not getting first row value of dataset1 onFetch() in dataset2 - beforeOpen() - birt

Dataset1 - table1 - onFetch()
reportContext.setPersistentGlobalVariable("ID", row["id"]);
Dataset2 - table2 - beforeOpen()
var id = reportContext.getPersistentGlobalVariable("ID");
In above dataset2 - beforeOpen() method not getting first row record value of dataset1 - table1....Values starting from 2nd row/record....last row value getting twice.

I cannot explain why your approach doesn't work, but it seems too complicated anyway.
You don't need the global variable. Instead, your detail/inner data set (bound to table 2) needs a data set parameter and you can set its value in the data set parameter binding dialog.

Related

Power Query - Modify tables before combining them

On my table (point1) I am trying to get, that for each table of the grouped rows (point 2) I will have new row inserted (point 3) at the beginning of each table with the value in the column "Metadata1" equal to value form "Column2" for original row number 2 (starting counting from 0).
Link to excel file:
https://filebin.net/cnb4pia0vvkg937g
Its hard to know how much of your requirement is generic or specific, but
TransformFirst = Table.TransformColumns(#"PriorStepName",{{"Count", each
#table(
{"Column1","Column2","Metadata1"},
{{_{0}[Column1],_{0}[Column2],_{2}[Column2]}}
) & _
}}),
Together=Table.Combine(TransformFirst[Count])
in Together
modifies all the tables in column Count to include an extra row that is made up up Row0/Col1 Row0/Col2 and Row2/Col2
It then combines all those tables into one table

How to use variable names of jdbc preprocessor in jsr223 preprocessor?

set variable names on jdbc preprocessor.
variable names : aa,bb
excute query
select aa, bb from table;
try to get the variable names on jsr223 preprocessor
log.info(vars.get("aa"));
but this via aa is null
how to use variable names?
Looking into JDBC Request Sampler documentation:
If the Variable Names list is provided, then for each row returned by a Select statement, the variables are set up with the value of the corresponding column (if a variable name is provided), and the count of rows is also set up. For example, if the Select statement returns 2 rows of 3 columns, and the variable list is A,,C, then the following variables will be set up:
A_#=2 (number of rows)
A_1=column 1, row 1
A_2=column 1, row 2
C_#=2 (number of rows)
C_1=column 3, row 1
C_2=column 3, row 2
So it will be:
vars.get('aa_1') - for first row of the aa column
vars.get('aa_2') - for second row of the aa column
vars.get('bb_1') - for first row of the bb column
etc.
More information: Debugging JDBC Sampler Results in JMeter

Passing the table header in Hive transform

I am creating a query in Hive to execute a R script. I am using transform function to pass the table. However when I receive the table in R it comes without the header. I know that I could create a variable and ask the user to insert the header manually but I do not wanna do it.
I wanna do something automatically, I am considering two options:
1) Figure out a way to pass the table with the header included when using transform function
2) Save the header in a variable and pass it in transform (I have already tried it in different ways but instead of passing the result of the query it is passing the query string - as seen below)
Here is what I have:
--Name of the origin table
set source_table = categ_table_small;
--Number of clusters
set k = "5";
--Distance to be used in the model
set distance = "euclidean";
--Folder where the results of the model will be saved
set dir_tar = "/output_r";
--Name of the model used in the naming of the files
set model_name ="testeclara_small";
--Samples: integer, number of samples to be drawn from the dataset.
set n_samples = "10";
--sampsize: integer, number of observations in each sample. This formula is suggested by the package. sampsize<-min(nrow(x), 40 + 2 * k)
set sampsize = "50";
--Creating a matrix which will store the sample number and the group of each sample according to the algorithm
CREATE TABLE IF NOT EXISTS medoids_result AS SELECT * FROM categ_table_small;
--In the normal situation you don't have the output label, it means you just have 'x' and do not have 'y', so you need to add one extra column to receive
--the group of each observation
--ALTER TABLE medoids_result ADD COLUMNS (medoid INT);
set result_matrix = medoids_result;
set headerMatrix = show columns in categ_table_small;
--Trainning query
SET mapreduce.job.name = K medoids Clara- ${hiveconf:source_table};
SET mapreduce.job.reduces=1;
INSERT OVERWRITE TABLE ${hiveconf:result_matrix}
SELECT TRANSFORM ($begin(cols="${hiveconf:source_table}" delimiter= "," excludes="y")$column$end)
USING '/usr/bin/Rscript_10gb /programs_r/du8_dev_1.R ${hiveconf:k}${hiveconf:distance}${hiveconf:dir_tar}${hiveconf:model_name}${hiveconf:n_samples}${hiveconf:sampsize}${hiveconf:headerMatrix}'
AS
(
$begin(table='${hiveconf:result_matrix}') $column$end
)
FROM
(SELECT *
FROM ${hiveconf:source_table}
DISTRIBUTE BY '1'
)t1;
You can add this line
hive -e 'set hive.cli.print.header=true;select * from tablename;'
Where tablename refers to your table name
If you want defaultly work for every table then you need to update the $HOME/.hiverc file with
hive> set hive.cli.print.header=true;
in the first line.

how to update value in a table from other table

I need to update value in table with (own value) - (value in other table Like) for an id
I have tried this
UPDATE FULLTABLE
SET FULLTABLE.Balance = FULLTABLE.Balance - AdvBalance.balance
WHERE FULLTABLE.id= AdvBalance.advid;
and this
update fulltable f set f.balance = ( f.balance -
select a.balance from advbalance a where a.advid=f.advertiserID)
first one is throwing error that invalid identifier. second one some other error.
I am using oracle db.
Please suggest a way to do this.
Thanks
You need a subselect to get the value from another table:
UPDATE FULLTABLE ft
SET ft.Balance = ft.Balance - (SELECT ab.balance
FROM AdvBalance ab
WHERE ft.id = ab.advid);
This will fail if it is possible that the subquery will return more than one row, but if this is the case, then you must decide how to find the right value to be subtracted.

SSRS - T-SQL - Concatenate multiple rows

I have T-SQL query that joins multiple tables. I am using that in SSRS as Dataset query. I am only selecting two columns, ID and Names. I have three records with same "ID" values but three different "Names" values. In SSRS, I am getting the first "Names" value and I need to concatonate all three values with same ID and have it in one cell on a table.
How would I go about doing that?
I am using lookup to combine cube + sql
Pulling ID straight from a table but using Case statement for Names to define alias.
You can accomplish this in TSQL either using PIVOT to get them as separate columns which you can then combine in the report cell, or you can use one of these concatenation methods to get all the names in one column.
For example, you can do this:
SELECT SomeTableA.Id,
STUFF(
(SELECT ',' + SomeTableB.Names AS [text()]
FROM SomeTable SomeTableB
WHERE SomeTableB.Id = SomeTableA.Id
FOR XML PATH('')), 1, 1, '' )
AS ConcatenatedNames
FROM SomeTable SomeTableA
INNER JOIN AnotherTable
ON SomeTableA.Id = AnotherTable.SomeId
...

Resources