Skip to main content
Solved

How to use an Attribute in an expression in a GI


Forum|alt.badge.img

Hi, 

 

I am having troubles converting my attribute value into a number for my expression.

I have an attribute applied on some stock items that is called UNITCOUNT which is just a field where I can enter a basic number.

Essentially a 10 count box the unit count attribute would be 10. Or in the same way, 10kg of powder would be 1000 servings so the unit count would be 1000. 

 

I was told to pull in the CSAttributeDetail Data Source but I am not sure that I connected it correctly.

 

The UNITCOUNT attribute displays in the GI perfectly, however, when I put it into an expression like:

=([AMMTranSplit.Qty]/ (CStr([InventoryItem.UNITCOUNT_Attributes]))

 

I then get an error when viewing the GI 

 

I was told to use CStr() or CDec() to make sure the attribute was converted into a useable number for the expression, but it is not working.

 

Any help on this would be greatly appreciated. 

 

Here is my GI attached:

Best answer by bwhite49

You have to go through CSAnswers. CSAttributeDetails is only relevant if the attribute is a combo box and you need the description from the attribute, not the just the value ID.

If you need the description, you will need to link CSAnswers to CSAttributeDetails through value = ValueID

You then use =([AMMTranSplit.Qty]/ (CInt([CSAnswers.value]))

View original
Did this topic help you find an answer to your question?

5 replies

bwhite49
Captain I
Forum|alt.badge.img+1
  • Captain I
  • 119 replies
  • Answer
  • April 7, 2025

You have to go through CSAnswers. CSAttributeDetails is only relevant if the attribute is a combo box and you need the description from the attribute, not the just the value ID.

If you need the description, you will need to link CSAnswers to CSAttributeDetails through value = ValueID

You then use =([AMMTranSplit.Qty]/ (CInt([CSAnswers.value]))


The issue seems to be with using CStr() in your expression, that actually converts the value into a string, which won’t work for division since you need a number.
Try using this expression: 
=[AMMTranSplit.Qty]/ CDbl([InventoryItem.UNITCOUNT_Attributes])

 


Forum|alt.badge.img

Hello ​@bodiec,

I found similar forum to answer your question.

Check below link.

hope, it helps


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 35 replies
  • April 7, 2025

Thanks ​@bwhite49 

 

I did add CSAnswers and connected them as you suggested. 

 

I have changed my expression to 

([AMMTranSplit.Qty]*[AMMTran.InvtMult])/(CDec([CSAnswers.Value])), 

 

However, I believe I have run into a new issue. 

I now have a “divide by zero error encountered”

 

I believe this happened because I haven’t filled in that attribute on all stock items yet, so there are some empty UNITCOUNTs.

 

Do you have any idea to get around this for a minute?

Maybe an iif expression that if it is not empty, then do the expression, or else 0?

Or do I just need to go through all my stock items to make sure it works?

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 35 replies
  • April 7, 2025

Actually I got it, 

 

It was a combination of both ​@bwhite49 and ​@CelineNwokeke54 

 

I linked the tables for CSAnswers and changed the formula to be CDbl() 

 

Final formula being:

=IIf( (CDbl([CSAnswers.Value]))<>' ', ([AMMTranSplit.Qty]*[AMMTran.InvtMult])/(CDbl([CSAnswers.Value])), 0)

 

Thank you all!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings