Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
fks
Contributor III
Contributor III

Aggr & Set analysis ?

Hi,

I have the following sample data:

DepartmentAccountObjectCodeSum(Amount)
410630010002006 800
410650010003004 225
41066001000500225
4207200 20077 425
4306100 800638 990
45135002000200-8 200
451610020008002 200
451620020008003 500
45135008000400-7 200
451610080008004 700
451620080008003 400
45235003000200-6 000
452610030008004 000
452620030008002 000
45235006000400-4 000
452610060008003 000
452620060008001 500
45335004000200-40 100
4536100400080048 800
453660040004001 000
45436005000200-5 050
454610050008004 100
45462005000800450
8607100 8003 000
860610020001008 200
864610030001006 000
8766200400010040 100
889610050001005 050
8906200 1007 500

 

I want to create a table of all Accounts that meets the following criteria (using wildcards):

Department = 45*

Account = 3*

Code = 200

 

DepartmentAccountObjectCodeSum(Amount)
45135002000200-8 200
451610020008002 200
451620020008003 500
45235003000200-6 000
452610030008004 000
452620030008002 000
45335004000200-40 100
4536100400080048 800
453660040004001 000
45436005000200-5 050
454610050008004 100
45462005000800450

 

I recon it's kind of a two-step process; first step to find the Objects related to Code 200 (where Department = 45* and Account = 3*) and then display the results where Department = 45*.

I tried to find a smooth solution with the Aggr function & Set analysis but haven't managed so far. So all help very much appreciated!

 

(I attach the sample data .qvd)

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

Try this

Sum({<Key = p({<Department = {"45*"}, Account = {"3*"}, Code = {"200"}>})>}Amount)

Where Key is a field created in the script like this

[SALES]:
LOAD *,
	 Department&Object as Key;
LOAD * INLINE [
	Department, Account, Object, Code, Amount     
    410, 6500, 1000, 300, 4225
    410, 6300, 1000, 200, 6800
    410, 6600, 1000, 500, 225
    420, 7200, , 200, 77425
    430, 6100, , 800, 638990
    451, 3500, 2000, 200, -8200
    451, 6100, 2000, 800, 2200
    451, 6200, 2000, 800, 3500
    451, 3500, 8000, 400, -7200
    451, 6100, 8000, 800, 4700
    451, 6200, 8000, 800, 3400
    452, 3500, 3000, 200, -6000
    452, 6100, 3000, 800, 4000
    452, 6200, 3000, 800, 2000
    452, 3500, 6000, 400, -4000
    452, 6100, 6000, 800, 3000
    452, 6200, 6000, 800, 1500
    453, 3500, 4000, 200, -40100
    453, 6100, 4000, 800, 42000
    453, 6600, 4000, 400, 1000
    453, 6100, 4000, 800, 6800
    454, 3600, 5000, 200, -5050
    454, 6100, 5000, 800, 4100
    454, 6200, 5000, 800, 450
    860, 6100, 2000, 100, 8200
    860, 7100, , 800, 3000
    864, 6100, 3000, 100, 6000
    876, 6200, 4000, 100, 40100
    889, 6100, 5000, 100, 5050
    890, 6200, , 100, 7500
];

View solution in original post

2 Replies
lironbaram
Partner - Master III
Partner - Master III

hi 

try this expression 

Sum({<Department={"45*"},Code={"200"},Account={"3*"}>}Amount)

sunny_talwar

Try this

Sum({<Key = p({<Department = {"45*"}, Account = {"3*"}, Code = {"200"}>})>}Amount)

Where Key is a field created in the script like this

[SALES]:
LOAD *,
	 Department&Object as Key;
LOAD * INLINE [
	Department, Account, Object, Code, Amount     
    410, 6500, 1000, 300, 4225
    410, 6300, 1000, 200, 6800
    410, 6600, 1000, 500, 225
    420, 7200, , 200, 77425
    430, 6100, , 800, 638990
    451, 3500, 2000, 200, -8200
    451, 6100, 2000, 800, 2200
    451, 6200, 2000, 800, 3500
    451, 3500, 8000, 400, -7200
    451, 6100, 8000, 800, 4700
    451, 6200, 8000, 800, 3400
    452, 3500, 3000, 200, -6000
    452, 6100, 3000, 800, 4000
    452, 6200, 3000, 800, 2000
    452, 3500, 6000, 400, -4000
    452, 6100, 6000, 800, 3000
    452, 6200, 6000, 800, 1500
    453, 3500, 4000, 200, -40100
    453, 6100, 4000, 800, 42000
    453, 6600, 4000, 400, 1000
    453, 6100, 4000, 800, 6800
    454, 3600, 5000, 200, -5050
    454, 6100, 5000, 800, 4100
    454, 6200, 5000, 800, 450
    860, 6100, 2000, 100, 8200
    860, 7100, , 800, 3000
    864, 6100, 3000, 100, 6000
    876, 6200, 4000, 100, 40100
    889, 6100, 5000, 100, 5050
    890, 6200, , 100, 7500
];