Skip to main content
Answer

Conditional Grouping in GI

  • July 23, 2025
  • 4 replies
  • 62 views

Forum|alt.badge.img

I’m trying to group in a GI by Lot/Serial Number for Stock Items, however, there are a few items without a serial number, and these are all being grouped together, despite being different lines (this is not a issue on Inventory Valuation for some reason.) Is there some way to do a conditional grouping? I tried =iif([InCostStatus.LotSerialNbr] <> ' ', [InCostStatus.LotSerialNbr], null) but the grouping happens even if the field is blank. Is there some way to do this?

Best answer by MichaelShirk

@kkraus  Oh right, because LotSerialNbr is a string, and CostID is a number. So (if) this approach were to work, the CostID value would need to first be converted to a string.
 

Maybe try this? 
 

=iif([InCostStatus.LotSerialNbr] <> ' ', [InCostStatus.LotSerialNbr], CStr([InCostStatus.CostID]))

4 replies

MichaelShirk
Captain II
Forum|alt.badge.img+5
  • Captain II
  • July 23, 2025

@kkraus this is a wild shot, but have you tried something like this? 

=iif([InCostStatus.LotSerialNbr] <> ' ', [InCostStatus.LotSerialNbr], [InCostStatus.CostID])

 

If an IF statement works for grouping, this should do it since the CostID is a key field and will always be unique.


Forum|alt.badge.img
  • Author
  • Freshman II
  • July 24, 2025

@kkraus this is a wild shot, but have you tried something like this? 

=iif([InCostStatus.LotSerialNbr] <> ' ', [InCostStatus.LotSerialNbr], [InCostStatus.CostID])

 

If an IF statement works for grouping, this should do it since the CostID is a key field and will always be unique.

@MichaelShirk I tried this, but got the error: “Error converting data type nvarchar to bigint.”


MichaelShirk
Captain II
Forum|alt.badge.img+5
  • Captain II
  • Answer
  • July 24, 2025

@kkraus  Oh right, because LotSerialNbr is a string, and CostID is a number. So (if) this approach were to work, the CostID value would need to first be converted to a string.
 

Maybe try this? 
 

=iif([InCostStatus.LotSerialNbr] <> ' ', [InCostStatus.LotSerialNbr], CStr([InCostStatus.CostID]))


Forum|alt.badge.img
  • Author
  • Freshman II
  • July 25, 2025

That worked perfectly. Numbers are accurate now.