This is a migrated thread and some comments may be shown as answers.

Q: Case Statement /w Crosstab Sum?

1 Answer 191 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 27 Dec 2013, 05:52 PM
Hi. I'm using a simple crosstab to generate totals and percentages, which I have already completed successfully
My data rows are as follows:

[=Fields.NameOfField]
Totals (Of each column)
Percentages (Of each column)
Savings (Of Each Column) <--- (This is what I want to calculate)

MAIN QUESTION ---> For the row labelled 'Savings', it is not just a count of what is in each column. I'd like to calculate my 'Savings' in a new row, based on what the Name of my Field is (Pseudo-ish code below), preferably in an EXPRESSION in the Telerik Report DESIGNER:

Savings = SUM( IF (Fields.NameOfField = 'Name1'), THEN (Savings = (1000-200) * Fields.Column1)
IF (Fields.NameOfField = 'Name2'), THEN (Savings = (750-150) * Fields.Column1) IF (Fields.NameOfField = 'Name3'), THEN (Savings = (500-100) * Fields.Column1) )

...But I am unsure how to generate a total this way. Please advise : )

1 Answer, 1 is accepted

Sort by
0
Hinata
Top achievements
Rank 1
answered on 01 Jan 2014, 09:28 AM
Hi Mike,

I'm not aware of your exact report structure, but you will probably need to nest the conditional statements in an expression like the following:

= Sum(IIf(Fields.NameOfField = 'Name1', (1000-200)*Fields.Column1,
       IIf(Fields.NameOfField = 'Name2', (750-150)*Fields.Column1,
          IIf(Fields.NameOfField = 'Name3', (500-100)*Fields.Column1, 0)
          )
       )
    )

You can learn expressions and how to use them in great detail here: Telerik Reporting Expressions.
Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Hinata
Top achievements
Rank 1
Share this question
or