Sum based on multiple conditions

Eshwar 216 Reputation points
2022-01-28T06:25:30.67+00:00

Hi,
I am trying to get total based on multiple conditions and it is giving error.
=sum(IIF(Fields!Field1.Value = "One", IIF(Fields!Field2.Value = 3, Fields!Amnt1.Value, Fields!Amnt2.Value),0))
Thanks,
Eshwar.

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,061 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Isabellaz-1451 3,616 Reputation points
    2022-01-28T07:29:47.213+00:00

    Hi @Eshwar

    I test the expression and it runs ok.

    Here is my test table :

    CREATE TABLE TEST1  
    (ID INTEGER IDENTITY(1,1),  
     Field1 VARCHAR(20),  
     Field2 INTEGER,  
     Amnt1 INTEGER,  
     Amnt2 INTEGER)  
      
      INSERT INTO TEST1  
      SELECT 'One',3,1,1  
        INSERT INTO TEST1  
      SELECT 'One',3,1,2  
    

    The textbox expression:
    169324-image.png

    And the preview result:
    169353-image.png

    Best Regards,
    Isabella


    If the answer is the right solution, please click "Accept Answer" and upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.