Can't remove duplicates from list generated from template Start expression

Good Day,

I am attempting to create a template that SUMS up list of the SKUs made for a specific Lot. I have tried several iterations of the Start expression with no luck.

See a generic dereference start expression below

<<Start: [Related Packagings]>>

<<SUM(SELECT(Packaging[E_QTY_EA],(AND([Product]=[_THISROW-1].[Product],[Lot#]=[_THISROW-1].[Lot#])),TRUE))>>

<<End>>

Output
1,080
1,080
2,520
2,520
2,520
2,520
2,520
2,520

The output is basically what I want except no duplicates, how can I remove them?

0 8 297
8 REPLIES 8

Steve
Platinum 4
Platinum 4

Tried both the start expression as well as the general expression, no luck same output

<<Start: UNIQUE(SELECT([Related Packagings][Id],(AND([Product]=[Product],[Lot#]=[Lot#]),TRUE))) >>

<<SUM(UNIQUE(SELECT(Packaging[E_QTY_EA],(AND([Product]=[_THISROW-1].[Product],[Lot#]=[_THISROW-1].[Lot#])),TRUE)))>> 

<<End>>

This:

<<Start: UNIQUE(SELECT([Related Packagings][Id],(AND([Product]=[Product],[Lot#]=[Lot#]),TRUE))) >>

Should probably be this:

<<Start: UNIQUE(SELECT([Related Packagings][Id],(AND([Product]=[_THISROW].[Product],[Lot#]=[_THISROW].[Lot#]),TRUE))) >>

That is what I thought, I get an error.

* Error 1 : 'New process 2' task 'New Task 2' Body template. Expression 'UNIQUE(SELECT([Related Packagings][Id],(AND([Product]=[_THISROW].[Product],[Lot#]=[_THISROW].[Lot#]),TRUE)))' is invalid due to: Error in expression '[_THISROW].[Product]' : Unable to find column 'Product'.
* Error 2 : 'New process 2' task 'New Task 2' Body template. Start expression 'UNIQUE(SELECT([Related Packagings][Id],(AND([Product]=[_THISROW].[Product],[Lot#]=[_THISROW].[Lot#]),TRUE)))' should generate a List of Ref values. Please verify that it generates a List and that the contents of the List are Ref values. Ref values should come from the 'Key' column of the referenced table.
* Error 3 : The document body is empty

In this (without the [_THISROW] dereferences):

<<Start: UNIQUE(SELECT([Related Packagings][Id],(AND([Product]=[Product],[Lot#]=[Lot#]),TRUE))) >>

To what [Product] and [Lot#] were you trying to compare the same column values of each related Packaging row?

Basically when I trigger the workflow on the parent table [Lot#] I want to sum up the quantities of the child table [related packagings] by [Product] (which is unique to [related packagings]), for which there are multiple entries. For example there may be 8 related packaging entries for only two [products].

Let me know if something is not clear

I also tried this version, of the Start statement, same issue

<<Start: UNIQUE(SELECT(Packaging[Id],(AND([Product]=[_THISROW].[Product],[Lot#]=[_THISROW].[Lot#]),TRUE))) >>```

You may wish to explore below.

Create

  1. A slice on the child table โ€œPackagingโ€. Slice called say โ€œSumQuantitiesโ€ with row filter expression [ID]=MINROW(โ€œPackagingโ€,"_ROWNUMBER", AND([Product]=[_THISROW].[Product],[Lot#]=[_thisrow].[Lot#]))

  2. A rev ref VC called say [RelatedSumPackagingQuantities] in the parent table โ€œLot#โ€ based on slice in 1) above. VC expression REF_ROWS(โ€œSumQuantitiesโ€, โ€œLot# table Keyโ€)

  3. A VC in the โ€œPackagingโ€ table called say [SumQuantitiesbyProduct] with expression
    SUM(SELECT(Packaging[E_QTY_EA], AND([Product]=[_THISROW].[Product], [Lot#]=[_THISROW].[Lot#])))

  4. The report template could look like something below

<<Start: [RelatedSumPackagingQuantities] >>

<<[SumQuantitiesbyProduct]>>

<< END >>

Hi @Suvrutt_Gurjar, that workaround makes sense to me. I will try it and let you know how it goes. Thanks

Top Labels in this Space