Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Use Variable in different DataSet
cambrown28
I need to set a variable with a value from a dataSet "meterDataSet"
Then use that variable as a label in a Table Header where that Table is tied to a different dataSet "multiAssetDataSet"
I have tried putting the following in the onFetch method of various dataSets and also in the initialise method:
reportContext.setPersistentGlobalVariable("Meter1", meterDataSet.getString("Meter1"));
When I try to recall the variable as a label using reportContext.getPersistentGlobalVariable("Meter1"); in the onCreate method of the label in a Table Header where that Table is tied to the dataSet "multiAssetDataSet", I don't see the data in the label.
Find more posts tagged with
Comments
Hans_vd
Hi cambrown28,<br />
<br />
Are you sure the data set meterDataSet is executed? If you are not using it elsewhere you can create a dummy item and bind the grid to it. It would be like it is described in <a class='bbc_url' href='
http://enterprisesmartapps.wordpress.com/2013/02/22/birt-columns-to-rows-in-data-set-part-2/'>this
post</a> under the Dummy Grid paragraph.<br />
<br />
If both data sets are selections in the same database, an alternative could be to retrieve the meter data in the multiAssetDataSet data set. Than you can just put the data bound item in the header just like that.<br />
<br />
Regards<br />
Hans
cambrown28
Hi Hans<br />
<br />
<blockquote class='ipsBlockquote' data-author="'Hans_vd'" data-cid="115431" data-time="1364367342" data-date="26 March 2013 - 11:55 PM"><p>
If both data sets are selections in the same database, an alternative could be to retrieve the meter data in the multiAssetDataSet data set. Than you can just put the data bound item in the header just like that.<br /></p></blockquote>
<br />
Can you please explain how to do this. How do I have 2 (or 3) different SQL statements in the open method of the multiAssetDataSet?<br />
<br />
Cam
Hans_vd
You can't.<br />
But you can join data together in one statement can't you?<br />
<br />
if you have<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>SELECT meter
FROM meters
WHERE id = 1</pre>
<br />
and you have<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>SELECT lots_of_fields
FROM multiasset</pre>
<br />
you can combine these in<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>SELECT (SELECT meter from meters WHERE id = 1) as meter,
lots_of_fields
FROM multiasset</pre>
<br />
Regards<br />
Hans
cambrown28
Hi Hans
Here are my 2 data select statements:
-- This gets the meter names (there will be 5 of these statements but I have only put one here for simplicity
With cte As
(Select ASSETNUM, metername,
Row_Number() Over(Partition By ASSETNUM Order By assetmeterid) As rn
From assetmeter where assetnum in
(select assetnum from multiassetlocci where recordkey = '1001' and recordclass = 'WORKORDER' and isprimary = 0
and multiid = (select MIN(multiid) from multiassetlocci where recordkey = '1001' and recordclass = 'WORKORDER' and isprimary = 0)))
Select [1] As Meter1
From cte
Pivot
(Max(metername) For rn In ([1])) As pvt
--This is the main statement
select multiassetlocci.assetnum, multiassetlocci.location, asset.description as assetdesc, multiassetlocci.startmeasure
from multiassetlocci
left outer join asset on multiassetlocci.assetnum = asset.assetnum and multiassetlocci.siteid = asset.siteid and multiassetlocci.orgid = asset.orgid
where multiassetlocci.siteid = 'BEDFORD'
and multiassetlocci.orgid = 'EAGLENA'
and multiassetlocci.recordkey = '1001'
and multiassetlocci.recordclass = 'WORKORDER'
and multiassetlocci.isprimary = 0
I can't seem to get the syntax correct to combine these 2 as you have suggested. Can you help with the syntax?
Or maybe there is a better way to write the first statement above.
The multiasset data is in a table like this:
1003 MOFLOOR3 Fire Extinguisher NULL
1007 OFF402 Fire Extinguisher NULL
1013 SWSTOCK Windows XP Operating System NULL
The meter data is in a table like this:
1003 ASSETCOND
1003 FUEL-L
1003 IN-PRESSUR
1003 RUNHOURS
1003 VIBRATION
Cam
Hans_vd
So you have Assetnum in both data sets?
In that case you can easily create a joint data set to join the data together.