Josef
Josef

Reputation: 2726

Sum values in RDLC with two datasets according to condition

I need to sum some values and show in RDLC. RDLC contains two datasets. There are two fields from same dataset; TipValute and Iznos. IF TipValute contains value 0 then sum all values from field Iznos.

My expression looks like:

=Sum(IIF(First(Fields!TipValute.Value=0, "DataSet1"),First(Fields!Iznos.Value, "DataSet1"),0))

But I'm getting error like

Error 3 The Value expression for the text box ‘Textbox96’ uses an aggregate expression without a scope. A scope is required for all aggregates used outside of a data region unless the report contains exactly one dataset.

and

Error 1 The Value expression for the textrun ‘Textbox96.Paragraphs[0].TextRuns[0]’ uses a First, Last or Previous aggregate in an outer aggregate. These aggregate functions cannot be specified as nested aggregates.

Than I tried with this expression

=Sum(IIf(Fields!TipValute.Value=0, Fields!Iznos.Value, 0), "DataSet1")

But in report i get #Error

What I'm doing wrong?

Upvotes: 1

Views: 3161

Answers (2)

Josef
Josef

Reputation: 2726

If should be:

Sum(IIf(Fields!TipValute.Value=0, cdbl(Fields!Iznos.Value), 0), "DataSet1")

Seems that the key was in cdbl

Upvotes: 1

VIJAY LAKHANI
VIJAY LAKHANI

Reputation: 54

Try This...

=Sum(IIF(Fields!TipValute.Value=0, Fields!Iznos.Value,0))

Upvotes: 1

Related Questions