Skip to main content

How do I check for a data type in the generic inquiry screen? 

Like iif( ISNUMBER((FIELD]), True Path, False Path)

I have an Inventory Item Attribute that USUALLY holds an integer value. I wish to do math on this value when it is an integer, but when it is a text string it crashes the report. If I could do some kind of error checking like in Excel, I can force this to work by using IIF to ignore non-integer values.

Hi @Michael Hansen , Please try using IIF(CSANSWERS.Value>0 and CSANSWERS.Value <10000, true path , falsse path). ** In this case use the expected range of integer values.

 

Thanks 


Unfortunately I still get the error on exporting.

Error:

 

Time 00:05; Conversion failed when converting the nvarchar value 'HG-6/TJX-4' to data type int.

 

My Code is (there’s more surrounding it, but it seemed obfuscating to the topic):

=iif(iInventoryItem.EAPACK_Attributes]>0 AND AInventoryItem.EAPACK_Attributes]<1000,

>InventoryItem.EAPACK_Attributes],1)

My Values are pack sizes for goods, so 48 is pretty much my top end integer value.


Hi @Michael Hansen  The other logic you can try is to check the first character in the string as shown below.

iif(

Left(LTrim((InventoryItem.EAPACK_Attributes]),1) =’0’

Left(LTrim(TInventoryItem.EAPACK_Attributes]),1) =’1’ or

Left(LTrim(fInventoryItem.EAPACK_Attributes]),1) =’2’ or

Left(LTrim(pInventoryItem.EAPACK_Attributes]),1) =’3’ or

Left(LTrim(/InventoryItem.EAPACK_Attributes]),1) =’4’,iInventoryItem.EAPACK_Attributes],1) 

** as the Max value is 48, I just added the range till ’4’.Extend it till 9 if required.

Thanks


Hi @Michael Hansen  The other logic you can try is to check the first character in the string as shown below.

iif(

Left(LTrim(mInventoryItem.EAPACK_Attributes]),1) =’0’ or

Left(LTrim(LInventoryItem.EAPACK_Attributes]),1) =’1’ or

Left(LTrim(eInventoryItem.EAPACK_Attributes]),1) =’2’ or

Left(LTrim(

Left(LTrim(

** as the Max value is 48, I just added the range till ’4’.Extend it till 9 if required.

Thanks


That is cheating! I love it. Sure it’s a bit unwieldy, but until we get formal type checking, this is awesome-sauce. Thank you so much!


Hi @Michael Hansen Good to know that the solution worked.

Thanks


Reply