Skip to main content
Answer

Concatenate string and integer fields on generic inquiry

  • June 23, 2023
  • 9 replies
  • 693 views

Forum|alt.badge.img

Hello, I am trying to concatenate string and integer fields from ARSalesPrice Table - InventoryID, CustPriceClassID, PriceType, CustomerID, BreakQty. 

 

The purpose of this GI is to count if we have duplicate prices at the same break qty. But currently, it does not let me concatenate string and integer fields together.  Could you please advise how that is achievable? 

Best answer by lauraj46

Hi @kanupindi ,

You can convert fields that are not strings to strings using the CStr function - something like this:

=CStr([ARSalesPrice.InventoryID]) + ‘ ‘ + CStr([ARSalesPrice.CustPriceClassID])

Beware that this formula will return the numeric codes for these fields.  When you display the InventoryID field by itself, the schema allows it to display the human readable code.  But in a formula it will return the numeric identifier.

If you want the InventoryCD field then you will probably need to add a join to the ItemInventory table and use [ItemInventory.InventoryCD] instead.  In that case the field would already be a string so you might not need the type conversion.

Hope this helps!

Laura

9 replies

lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • Answer
  • June 23, 2023

Hi @kanupindi ,

You can convert fields that are not strings to strings using the CStr function - something like this:

=CStr([ARSalesPrice.InventoryID]) + ‘ ‘ + CStr([ARSalesPrice.CustPriceClassID])

Beware that this formula will return the numeric codes for these fields.  When you display the InventoryID field by itself, the schema allows it to display the human readable code.  But in a formula it will return the numeric identifier.

If you want the InventoryCD field then you will probably need to add a join to the ItemInventory table and use [ItemInventory.InventoryCD] instead.  In that case the field would already be a string so you might not need the type conversion.

Hope this helps!

Laura


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • June 23, 2023

Hi @lauraj46 , thank you for your swift response as always! Looks like it worked, I will get back to you after testing few results. Have a great day!


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • July 20, 2023

Hi @lauraj46,  thank you for your help so far. The suggestion you provided worked.  I was hoping if you could help me something. I am trying to count count duplicate sales prices on my GI. I only want it to count if a price exists with same inventory id, break qty, price type. How can I achieve that? 

In the below case, the count should say 0 and not 3. 

Example

I am currently counting the concatenated field - Inventory ID, Customer ID, Break Qty

Thank you for your help in advance!
Regards, 

Kaavya


lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • July 20, 2023

Hi @kanupindi ,

In order to use the count function you need to group on the other fields.  See attached example.

Hope this helps!

Laura

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • July 20, 2023

Hi @lauraj46, Thank you for your swift response and sharing the xml file. I think it is still counting all the prices that is active for that item in the system. I actually want it to only count when there is a price for the same item, price type and break qty. I tried on my GI and now everything shows up with a count value of 1. Not sure if I missed something?


lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • July 20, 2023

Hi @kanupindi ,

In order for the count to work correctly, all of the fields in your results should be either grouped or counted.  If it still doesn't work, please attach the XML for your query.

Laura 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • July 20, 2023

Hi @lauraj46 , thank you. I am grouping by fields that have been used for concatenation. But count still shows up as 0. Below is an example I tested:

The result for count should be 2. I have attached the xml file, thank you again!

 


lauraj46
Captain II
Forum|alt.badge.img+8
  • Captain II
  • July 21, 2023

Hi @kanupindi ,

The count is returning 0 because one or more of the fields in the concatenated string formula is null, resulting in a null string. The aggregate COUNT function counts the number of non-null values.

Rather than building a concatenated string, why not just show each field separately and use the <count> field to count the number of rows?  For this to work you should group on all of the same fields that are displayed in your results table.  A revised XML file is attached.

Laura


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • July 21, 2023

Hi @lauraj46, Thank you for your help! This works how we want it to! Have a great day!

 

Regards,

Kaavya