Skip to main content
Solved

Variable showing a blank field

  • June 10, 2026
  • 11 replies
  • 60 views

I’ve created a variable to sum the total amount shipped of an item during a specific time period.  However, if zero of this item are shipped, the variable is blank, instead of outputting 0.  Can someone review my code and hopefully point out what I have been overlooking?

 

Many thanks in advance.

 

=IIF($DateDiff > 2,CInt(SUM(IIF([SOShipment.ShipDate] >= CDate(CStr(Month(DateAdd(@EndDate,'m',-2))) + '/1/' + CStr(Year(DateAdd(@EndDate,'m',-2)))) AND [SOShipment.ShipDate] <= @EndDate,
[SOShipLineSplit.Qty],0))),0)

Best answer by lauraj46

Hi ​@MSmithDPG ,

Try =’0’ instead of =‘#’ as the format string.  I’m still unsure why it doesn’t work as is, because the variable value should in fact be 0.  Seems to be something about processing order related to the IIF, even though both the true and false expressions are numeric. 

In any event, =’0’ will force the control to print a 0 if the value is null.  Also if you leave the format string blank or use something like [INSiteStatus.QtyOnHand.Format] that worked in my testing. Hopefully one of these format options will accomplish what you need.

11 replies

lauraj46
Captain II
Forum|alt.badge.img+9
  • Captain II
  • June 10, 2026

Hi ​@MSmithDPG ,

In the case when there are no details for the overall query on an inventory group, perhaps it is not executing the formula at all?  Is your variable in the header or the footer section of the item group?  You can use the ResetGroup and ResetExpr properties on the variable to reset the expression to 0 on each group.  I don’t see any issue with the formula itself, but you could also try wrapping your expression with the IsNull function:

=IsNull(IIF($DateDiff > 2,CInt(SUM(IIF([SOShipment.ShipDate] >= 				CDate(CStr(Month(DateAdd(@EndDate,'m',-2))) + '/1/' + CStr(Year(DateAdd(@EndDate,'m',-2)))) AND [SOShipment.ShipDate] <= @EndDate,[SOShipLineSplit.Qty],0))),0),0)

Let me know if one of these ideas helps!


  • Author
  • Freshman I
  • June 10, 2026

Hello ​@lauraj46,

I tried wrapping the expression with IsNull with no success.

I have the variable in the header section and it is set to reset with the group based on InventoryID

 


lauraj46
Captain II
Forum|alt.badge.img+9
  • Captain II
  • June 10, 2026

@MSmithDPG , would you be able to attach the rpx file to this thread so I can take a look?


  • Author
  • Freshman I
  • June 10, 2026

@lauraj46,

Here you go.


WillH
Semi-Pro II
Forum|alt.badge.img+4
  • Semi-Pro II
  • June 10, 2026

@MSmithDPG -
Is there a chance this is happening due to a ViisibleExpr on the field or the band/group it is in?
 

 


  • Author
  • Freshman I
  • June 10, 2026

@WillH,

The field will appear and show values for items that have been shipped, just not 0 shipped items.

That said, the field shows so long as the datediff is greater than 2.

 


lauraj46
Captain II
Forum|alt.badge.img+9
  • Captain II
  • Answer
  • June 10, 2026

Hi ​@MSmithDPG ,

Try =’0’ instead of =‘#’ as the format string.  I’m still unsure why it doesn’t work as is, because the variable value should in fact be 0.  Seems to be something about processing order related to the IIF, even though both the true and false expressions are numeric. 

In any event, =’0’ will force the control to print a 0 if the value is null.  Also if you leave the format string blank or use something like [INSiteStatus.QtyOnHand.Format] that worked in my testing. Hopefully one of these format options will accomplish what you need.


  • Author
  • Freshman I
  • June 10, 2026

@lauraj46,

 

I tried both the ‘0’ and using the INSite format and unfortunately, still no dice.

 


lauraj46
Captain II
Forum|alt.badge.img+9
  • Captain II
  • June 10, 2026

@MSmithDPG That's odd because it worked for me.  I noticed that you have some overlapping controls.  Could you try moving one to a different spot and removing the visibility condition to make sure they are not conflicting and that it's not a visibility issue?


lauraj46
Captain II
Forum|alt.badge.img+9
  • Captain II
  • June 10, 2026

@MSmithDPG ,

See screenshots below for your reference.

 


  • Author
  • Freshman I
  • June 10, 2026

@lauraj46 ,

 

Sorry for the slow reply (had to go wear one of my many other hats) but I figured out the issue.  Your initial suggest of using INSite for the formatting worked.  In my rush to move from task to task, I forgot to swap the report version back from my “working” version to the “test” version.

It was driving me crazy that the coding looked right but the formatting was throwing it through a loop for some reason.

Now I can adjust another variable and start adding in my subreports.

Thank you for all of your help.  It’s much appreciated.