Question

I'm having difficulty with what seems to be a limitation in SSRS (BIDS) 2005, and upgrading to a newer version is not yet an option for me.

I have a DataSet that returns a bunch of payroll withholding data by employee, and I'm wanting to get the value of field "B" based on what I find in field "A." Specifically, I want to get a dollar amount based on a field "Code" being "OptlLife."

So, if Field A = "OptLife" give me the dollar value of Field B. Pretty simple, right?

The closest I can come is:

=IIF(First(Fields!Code.Value, "Withholdings") = "OptLife", First(Fields!AmtPct.Value, "Withholdings"), " ")

What's killing me is that "First" indicator. I don't want "first" or "last" or "max" or "sum." I want whatever row of data has the value OptLife. If I remove that indicator, I get a syntax error. How do I get around this?

What I really want is something like "select AmtPct from WithholdingsDataSet where Code = "OptLife" but it needs to be an SSRS expression.

EDIT PER IAN'S QUESTION:

So, I have a result set from the DataSet that looks like this.

Employee    Code        Method  AmtPct
1121        401K        A       400
1121        Roth        null    null
1121        FSAChild    A       96.15
1121        FSAHealth   A       192.31
1121        OptLife     A       28.84

In my report, I have a textfield formatted for Currency, and need an expression that will pull the 28.84 into that field. Because I have multiple DataSets tied to this report, I need to specify which DataSet the value is coming from, hence the (Fields!Code.Value, "Withholdings") but that parenthetical statement has to be prepended with something. Nothing I put there gives me the value I need.

Once I nail this down, the same methodology will be used for distinguishing Roth and Traditional 401K, and FSA Childcare from FSA Healthcare.

Was it helpful?

Solution

You should be able to use something like:

=Sum(IIF(Fields!Code.Value = "OptLife", Fields!AmtPct.Value, Nothing), "Withholdings")

As you've seen, since you're referencing the data in a Textbox you need to use an aggregate expression.

The expression above will apply a Sum to the dataset, but will only consider OptLife rows, which seems to be what you're after. Assuming you only have one OptLife code in the Dataset, you'll only be considering that one row in the aggregate, which I think is what is required.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top