Filtering data in SSRS Query

Hi,

Below is the sample code written to filter the data based on Query used by report and apply on custom query in DP class;

//DP class

queryVendInvoiceJour=this.parmQuery();

//Get filtered/selected value from standard query 
qrOrderAccount = queryVendInvoiceJour.dataSourceName(‘VendInvoiceJour’).rangeField(fieldNum(VendInvoiceJour,OrderAccount));

//Writing custom query based on requirement but applying the selected ranges to custom query

q=new Query();
qbdsVendInvoiceJour = q.addDataSource(tablenum(VendTrans));
qrVendInvoiceJour = qbdsVendInvoiceJour.addRange(fieldNum(VendTrans,AccountNum));
q.dataSourceNo(1).rangeField(fieldNum(VendTrans,AccountNum)).value(qrOrderAccount.value());

qr = new QueryRun(q);

 

This will help to overwrite the Query used in Report using the custom query by applying same ranges selected by user.

HAPPY DAXing 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s