Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I've the below two expression, I would like to do them in the load script instead of set expression. '*Exec*' is nothing but a wild match
=sum({<candidate={"*Exec*"}>}Sales)+sum({<candidate={"*Exec1*"}>}Sales)
=sum({<candidate={"*Exec2*"}>}Sales)+sum({<candidate={"*Exec1*"}>}Sales)
Let me know how to achieve it.
Regards,
V
Try below
data:
Load *
Inline [
candidate,Sales
Exec-123,100
Exec1-567,200
Exec2-890,300
Exec-123,400
Exec-123,500
Exec-123,600
Exec1-567,700
Exec1-567,800
Exec2-890,900
Exec2-890,1000
];
NoConcatenate
Temp:
Load
Sum(Sales) as ex_Sales
Resident data
where not wildmatch(candidate,'*Exec1*','*Exec2*')
group by candidate
;
Join
Load
candidate,
Sum(Sales) as Sales
Resident data
where wildmatch(candidate,'*Exec1*','*Exec2*')
group by candidate
;
drop table data;
NoConcatenate
Final:
Load candidate,
Sum(ex_Sales + Sales) as Sales
Resident Temp
group by candidate
;
Drop table Temp;
Regards,
Prashant Sangle
Can you share sample data with required output?
Hi @PrashantSangle ,
Below is the example data
candidate | Sales |
Exec-123 | 100 |
Exec1-567 | 200 |
Exec2-890 | 300 |
Exec-123 | 400 |
Exec-123 | 500 |
Exec-123 | 600 |
Exec1-567 | 700 |
Exec1-567 | 800 |
Exec2-890 | 900 |
Exec2-890 |
1000 |
Expected Output
candidate | Sales |
Exec1-567 | 3,300 (100+200+400+500+600+700+800) |
Exec1-890 | 3,800 (100+300+400+500+600+900+1000) |
Try below
data:
Load *
Inline [
candidate,Sales
Exec-123,100
Exec1-567,200
Exec2-890,300
Exec-123,400
Exec-123,500
Exec-123,600
Exec1-567,700
Exec1-567,800
Exec2-890,900
Exec2-890,1000
];
NoConcatenate
Temp:
Load
Sum(Sales) as ex_Sales
Resident data
where not wildmatch(candidate,'*Exec1*','*Exec2*')
group by candidate
;
Join
Load
candidate,
Sum(Sales) as Sales
Resident data
where wildmatch(candidate,'*Exec1*','*Exec2*')
group by candidate
;
drop table data;
NoConcatenate
Final:
Load candidate,
Sum(ex_Sales + Sales) as Sales
Resident Temp
group by candidate
;
Drop table Temp;
Regards,
Prashant Sangle
@vikasshana I tried the below Code,
NoConcatenate
Temp:
Load * Inline [
candidate, Sales
Exec-123, 100
Exec1-567, 200
Exec2-890, 300
Exec-123, 400
Exec-123, 500
Exec-123, 600
Exec1-567, 700
Exec1-567, 800
Exec2-890, 900
Exec2-890, 1000
];
NoConcatenate
Temp1:
Load candidate,
Sum(Sales) as Total_Sales
Resident Temp
where not WildMatch(candidate,'*Exec1*','*Exec2*')
group by candidate;
Concatenate(Temp1)
Load candidate,
Sum(Sales) as Total_Sales
Resident Temp
where WildMatch(candidate,'*Exec1*','*Exec2*')
group by candidate;
Drop table Temp;
Exit Script;
Let me know if it is something that you are looking for.
thank you @PrashantSangle and @sidhiq91 for the suggestion, but I would like to see output as below.
candidate | Sales |
Exec1-567 | 3,300 (100+200+400+500+600+700+800) |
Exec1-890 | 3,800 (100+300+400+500+600+900+1000) |
Thanks for that @PrashantSangle , it is working as expected.