IIf and expressions

I like to print a conditional to a parameter. I entered an expression as follows:

[IIf([newpage_groepveld]=="1" , [Table.afroepregels_refentie] , [Table.afroepregels_plantnaam])]

Because IIf is a VB syntax I tried the C# syntax also:
[newpage_groepveld]=="1" ? [Table.afroepregels_refentie] : [Table.afroepregels_plantnaam];

Both do not work.

How can I conditional print the one or the other field?

Tia
Hans

Comments

  • edited 6:14PM
    Hello,

    Both
    [IIf([newpage_groepveld]=="1" , [Table.afroepregels_refentie] , [Table.afroepregels_plantnaam])]
    and
    newpage_groepveld]=="1" ? [Table.afroepregels_refentie] : [Table.afroepregels_plantnaam
    must work. The "newpage_groepveld" report parameter must be of String type. If it is numeric, use ... == 1 instead of ... == "1".
  • edited 6:14PM
    I used this expression at the GroupHeader Band Condition. Here this results in an error CS1525 followed by CS1002.

    Is this caused because we using an expression with a "IIf"in a group header?
    BTW, we can use expression like [Table.col1] + [Table.col2], it only fails when we add the "IIf" construction.

  • edited 6:14PM
    In this case you don't need outer brackets:
    IIf([newpage_groepveld]=="1" , [Table.afroepregels_refentie] , [Table.afroepregels_plantnaam])
    (they are needed if you print this in the Text object).

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.