Skip to main content
Answer

Help with variable expression

  • February 4, 2025
  • 3 replies
  • 59 views

Forum|alt.badge.img

Hi all,

I’m calculating labor cost for a generic inquiry using this:

=Round( CInt( [AMProdTotal.ActualLaborTime] ) /60.00 , 2 ) * 47.33

But, I would like change that default rate if the following user names are true:

=iif(InStr([CreatedByUser.Username], 'barcode')>0 or InStr([CreatedByUser.Username], 'slitter')>0, Cint([AMMTran.LaborTime]), 0)

Is there a way to say, labor rate is 94.66 if username contains “X” or “Y”, otherwise labor rate is 47.33?

 

Also, I’m trying to calculate the labor time here based on username, converting the minutes into hours, but I have this messed up! (probably the parentheses!) Any ideas?

Thanks for any input!

Best answer by lauraj46

Hi ​@swartzfeger ,

Try this:

=Round( CInt( [AMProdTotal.ActualLaborTime] ) /60.00 , 2 ) * iif((InStr([CreatedByUser.Username], 'barcode')>0 or InStr([CreatedByUser.Username], 'slitter')>0) and CDbl([InventoryItem.UsrCNbrofColors])>0, 94.66, 47.33)

I don't think the expression builder is C#.  If you click the pencil icon, it opens a formula builder and you can expand the tree to see the available functions and operators.

Hope this helps!

Laura 

3 replies

lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • February 4, 2025

Hi ​@swartzfeger ,

You can combine the two formulae like this:

=Round( CInt( [AMProdTotal.ActualLaborTime] ) /60.00 , 2 ) * iif(InStr([CreatedByUser.Username], 'barcode')>0 or InStr([CreatedByUser.Username], 'slitter')>0, 94.66, 47.33)

Hope this helps!

Laura


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • February 4, 2025

Hi ​@swartzfeger ,

You can combine the two formulae like this:

=Round( CInt( [AMProdTotal.ActualLaborTime] ) /60.00 , 2 ) * iif(InStr([CreatedByUser.Username], 'barcode')>0 or InStr([CreatedByUser.Username], 'slitter')>0, 94.66, 47.33)

Hope this helps!

Laura

Laura thank you SOO much… that works but I forgot one part of the variable:

if username is ‘x’ or ‘y’ AND [InventoryItem.UsrCNbrofColors] is GREATER  THAN 1

Sorry for the bother, I need to search for a guide on how to write variable expressions (I think it’s just garden variety C#?)


lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • Answer
  • February 4, 2025

Hi ​@swartzfeger ,

Try this:

=Round( CInt( [AMProdTotal.ActualLaborTime] ) /60.00 , 2 ) * iif((InStr([CreatedByUser.Username], 'barcode')>0 or InStr([CreatedByUser.Username], 'slitter')>0) and CDbl([InventoryItem.UsrCNbrofColors])>0, 94.66, 47.33)

I don't think the expression builder is C#.  If you click the pencil icon, it opens a formula builder and you can expand the tree to see the available functions and operators.

Hope this helps!

Laura