简体   繁体   中英

Store dataset count as a variable in a report to use in other tables - SSRS

We have 2 queries on an SSRS report .

One query returns a single number that is a total record count. The other query returns a single column that we'd like to divide by the total returned in the first query.

So

Query 1 DATASET (this will always return a single value)

TOTAL  
100

Query 2 DATASET (this will return a list of values we'd like to divide by q1 answer)

COL A
1
20
3
49

What we want to show on the report

RATIO (A/Total)
1/100
20/100
3/100
49/100

Not show how to marry these two datasets in a single ssrs tablix. The 100 is not an aggregate of any value in the table from set 2, its a totally different number so I don't know of a way to write a query to bring out these values ins a single dataset.

Ideas?

thanks,.

MC

If you don't want to combine your datasets, you can do the following to achieve your end result.

For the dataset that returns a single value, you could create a report parameter (@MyParam) that is hidden and is populated by your dataset Query1. Your dataset for Query2 can remain as it was. Then you can use the following expression to populate a textbox in your report

=CString(Fields!ColA.value) &"/"& CString(Parameters!MyParam.value) 

If that is put in a list or table, it will go through each value in ColA and produce your desired result.

Why not do one data set? Err...I assume you want to see 49/100 and not .49 with this answer

select q2.A + '/' + q1.value as 'output'
from query2 q2, query1 q1

It's a cross join and applies q1 values to all q2 (since q1 is just one value, this'll work)...query1 and query 2 can be replaced with whatever queries you want to have there...you'll need to provide the SQL for q1 and q2 if you want a more full answer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM