5

I have a .rdlc report, grouped. Inside each group, I have an Id. Some of them will be positives, and others will be negative. I need the difference between de quantity of positives Id's and negatives Id's

Something like

=CountDistinct(Fields!Id.Value) where Fields!Id.Value > 0 - CountDistinct(Fields!Id.Value) where Fields!Id.Value < 0

How Can I do that ? I'm thinking on a function, but I want to know if there is a simply way

Edit: An Id can be more than once time in each group, that's why I use CountDistinct

rene
  • 41,474
  • 78
  • 114
  • 152
Gonzalo.-
  • 12,512
  • 5
  • 50
  • 82

2 Answers2

3

You can try this:

CountDistinct(IIf(Fields!Id.Value > 0, Fields!Id.Value, Nothing))
Daniel Rosenthal
  • 1,386
  • 4
  • 15
  • 32
Mike
  • 843
  • 7
  • 13
0

create 2 global variables. one for positive and one for negative.

Then create a new formula that counts them like the following:

WhilePrintingRecords;
IF (GroupName ({your_group_name}) > 0) THEN
    Positive var = Positive var + 1;
ELSE 
    Negative var = Negative var + 1;

You can actually look for your group in the formulas and drag it to the editor while writing the formula.

Since its a operation in group level, the records should be read first. Thats why we use whilePrintingRecords rather than whileReadingRecords.

Hope I understood your question right.

Misa J.
  • 167
  • 1
  • 5
  • this is very old - already modify the query and don't need this. Anyway, thanks :) But when I want to do this, I want to precisally avoid a function - that's why I said " I'm thinking on a function, but I want to know if there is a simply way". I was(still I am) newbie about .rldc, so I was asking if there's already a primitive funcion that do this job for me. Thanks anyway! – Gonzalo.- Nov 01 '12 at 17:33