Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sum of sales

Hi i have two tables

 

Table A
S.nocodeDoc.codeTotal
1ILE100120
2ILE100240
3ILE100330
4ILE100450
5ILE100580
Table B
s.nocodeRef codeRef Doc codeTotal
1SRLEILE100220
2SRLEILE100440
3SRLEILE100580

Given above are two tables. i want the sum of sales for ILE by subtracting the values from table B

ie. second table is my sales return and first table is invoice.  if sales return hapens i need to return the money so it wont count as profit..

how to achieve this type..

please help

Thanks

Vignesh

2 Replies
swuehl
MVP
MVP

One possible way would be to concatenate both tables, renaming Ref Doc code to Doc code and multiplying the Total with -1.

then you can aggregate Total grouped by Doc code and you should see the correct amount.

saimahasan
Partner - Creator III
Partner - Creator III

Do you want something like this:

Untitled.png

Table1:

LOAD * Inline [

S.no, code, Doc.code, Total

1, ILE, 1001, 20

2, ILE, 1002, 40

3, ILE, 1003, 30

4, ILE, 1004, 50

5, ILE, 1005, 80

];

Join

LOAD * Inline [

s.no, S_code, code, Doc.code, S_Total

1, SRLE, ILE, 1002, 20

2, SRLE, ILE, 1004, 40

3, SRLE, ILE, 1005, 80

];

T2:

LOAD *,

Total - If(IsNull(S_Total),0,S_Total) as NewTotal

Resident Table1;

DROP Table Table1;