Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 satishkurra
		
			satishkurra
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi
I'm trying to create a flag for Sales > 0 and < 0 as below in the script.
But it is displaying as Invalid Expression on reload.
Can someone help me what went wrong?
LOAD
ID,
Sales,
If(Sum(Sales) > 0, 1,0) as SalesFlag;
SQL SELECT * FROM ......
 
					
				
		
 MarcoWedel
		
			MarcoWedel
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		In case you only want a flag per individual sales value / row of your source table, one solution might be:
LOAD ID,
Sales,
Sign(Sales) as SalesFlag;
SQL SELECT * FROM ......
or
LOAD ID,
Sales,
If(Sales, 1, 0) as SalesFlag;
SQL SELECT * FROM ......
hope this helps
regards
Marco
 sunny_talwar
		
			sunny_talwar
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Try this:
Table:
LOAD ID,
Sales;
SQL SELECT * FROM ......
Left Join (Table)
LOAD ID,
If(Sum(Sales) > 0, 1, 0) as SalesFlag
Resident Table
Group By ID;
 
					
				
		
 Colin-Albert
		
			Colin-Albert
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		To use an aggregation expression in your load script, you must include a group by clause.
sunindia shows how you can do this.
 satishkurra
		
			satishkurra
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Can we include SET ANALYSIS in above Sum(Sales) in script window?
Also the above is still throwing error
 satishkurra
		
			satishkurra
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Seems like i have the SQL statement and it is not supporting to use it.
I will use Preceding Load before this and see if i can achieve this?
 satishkurra
		
			satishkurra
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		I tried different way, it is not working, Can someone help me to achieve this using SET expression in script window?
 satishkurra
		
			satishkurra
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		I tried different way, it is not working, Can someone help me to achieve this using SET expression in script window?
 sunny_talwar
		
			sunny_talwar
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		There is not set analysis in the script. You can use ifs or Where statements to restrict things. Do you know what you are restricting?
 satishkurra
		
			satishkurra
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		I'm basically restricting the sales <0 and > 0
 
					
				
		
 MarcoWedel
		
			MarcoWedel
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		In case you only want a flag per individual sales value / row of your source table, one solution might be:
LOAD ID,
Sales,
Sign(Sales) as SalesFlag;
SQL SELECT * FROM ......
or
LOAD ID,
Sales,
If(Sales, 1, 0) as SalesFlag;
SQL SELECT * FROM ......
hope this helps
regards
Marco
