Search code examples
vb.netreport-viewer2010

IIF Statement in ReportViewer Returns False


Okay so I am trying to do math in this IIF statement in reportviewer. However, all it does is return FALSE in my field. Am I able to do math with an IIF statement or what?

=IIF(
     UCase(Fields!Tax.Value) = "YES", 
     Variables!DeptTotal.Value =+(Fields!TotalPriceWithoutTax.Value * (1 + Parameters!Tax.Value)), 
     Variables!DeptTotal.Value =+ (Fields!TotalPriceWithoutTax.Value)
     )

Any Ideas? Thanks in advance.

EDIT:

Okay Guys,

I even did a custom codes and it still returns false.

Public Function Taxable(Answer AS String, DepartTotal AS Decimal, TotalWithoutTax AS Decimal, Tax AS Decimal) AS Decimal

    If UCase(Answer) = "YES" Then

         DepartTotal += TotalWithoutTax * Tax 

    Else

       DepartTotal +=  TotalWithoutTax

    End If

    Return DepartTotal

End Function

Any other sugguestions?

Thanks Again.

EDIT:

This is my taxable function call:

=Code.Taxable(Tax, DepartTotal, TotalWithoutTax, txtTax.value)

Solution

  • This is the fix:

    The function:

    Public Function Taxable(Answer AS String, TotalWithoutTax AS Decimal, Tax AS Decimal) AS Decimal
    
           Dim total AS Decimal = 0
    
           If UCase(Answer) = "YES" Then
    
                 total = TotalWithoutTax *  (1 + Tax)
    
            Else
                 total = TotalWithoutTax
    
            End If
    
            Return total
    
    End Function
    

    The Call:

    Code.Taxable(Fields!Tax.Value, Sum(Fields!TotalPriceWithoutTax.Value), Parameters!Tax.Value)