Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
dmohanty
Partner - Specialist
Partner - Specialist

If Else Question

Hello Experts,

I have a common table, which is formed by Concatenation of two Load Scripts.

Price:

Load * Inline [

Old Account, Account Name,  Price

100, John, $500

200, Mary, $350

300, Alex, $0

400, Harry,$1050

500, King , $700

]:

CONCATENATE

Load * Inline [

New Account, Account Name, Price

1000, John, $450

2000, Mary, $0

3000, Alex, $0

4000, Harry, $1200

5000, King , $700

]:

 

Criteria:

  • If there is Price existing in Second Table for New Account - display the New Price (from 2nd table)
  • If there is no Price ($0 or blank) in Second Table for New Account - display the Old Price (from 1st table)
  • if the Old Price and New Price are same show any one/New Price (2nd table).

Expected Outcome

Old AccountNew Account Account Name Price
1001000John$450
2002000Mary$350
3003000Alex$0
4004000Harry$1,200
5005000King$700

 

Any help would be appreciated! 🙂 

Regards!

1 Reply
rubenmarin

Hi @dmohanty, you can do that with this script:

tmpPrice:
Load * Inline [
Old Account, Account Name,  OldPrice
100, John, $500
200, Mary, $350
300, Alex, $0
400, Harry,$1050
500, King , $700
];

Outer Join // Merge in the same row by Account Name
Load * Inline [
New Account, Account Name, NewPrice
1000, John, $450
2000, Mary, $0
3000, Alex, $0
4000, Harry, $1200
5000, King , $700
];

Price:
LOAD
	[Old Account],
	[New Account], 
	[Account Name],
	If(not IsNull(NewPrice) and NewPrice<>'$0', NewPrice, OldPrice) as Price
Resident tmpPrice;

DROP table tmpPrice;