Search code examples
c#visual-studio-2010rdlcdynamic-rdlc-generation

Formatting a summed number within an iif in RDLC


I cannot seem to figure out how to format a number within a textbox that is being summed within an iif. Here is how my code looks:

=iif(
  SUM(
   iif(expression, number1+number2+number3, number4+number5+number6)
      )
    )>=10000000,true, false)        

In the part that says true I would like to format the number being summed, but it is being used in the comparator as well. Normally I would just assign the sum to a variable and continue with the conditional check, but I am not sure how to proceed. Is there a way to assign variables within a textbox expression, or am I coming at this the wrong way?


Solution

  • Try this example, using a TextBox called YourTextBox:

    //set value
    YourTextBox.Value = Sum(IIf(expression, num1 + num2 + num3, num4 + num5 + num6))
    
    //format value
    YourTextBox.Format = IIf(ReportItems!YourTextBox.Value >= 10000000, "c2", "f2")
    
    //format style
    YourTextBox.BackgroundColor = IIf(ReportItems!YourTextBox.Value >= 10000000, "Red", "Lime")