Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
 abhaysingh
		
			abhaysingh
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi All,
I have one MinTemperature field and MaxTemperature Field. and one Current Temperature field..
I want to Calculate the Delta for this. e.g. Let Say Delta will be calculative on the basis of nearest Min or MaxTemp. in Below first case MinTemp is 1 and max is 5, but Current temp is 0.5 which is nearer to MinTemp so Delta is CurrentTemp - MinTemp.
| MinTemp&''&MaxTemp | CurrentTemp | Delta | 
|---|---|---|
| 1 to 5 | 0.5 | 0.5 | 
| 2 to 5 | 6 | 1 | 
| -1 to 5 | -1.2 | 0.2 | 
Please suggest.
Thanks
Abhay
 Gysbert_Wassena
		
			Gysbert_WassenaTry rangemin(fabs(CurrentTemp-MinTemp),fabs(CurrentTemp-MaxTemp))
 
					
				
		
 abhaysingh
		
			abhaysingh
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		thanks gysbert,
I have one scenario in which Min-Max Range is -40 to -18 and current temp is -17.5 and getting output 0.5, i think it should be -0.5. pls suggest
 
					
				
		
 abhaysingh
		
			abhaysingh
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		pls revert thanks
 
					
				
		
 abhaysingh
		
			abhaysingh
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		hi Please Revert
 rubenmarin
		
			rubenmarin
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi abhay, you can try with:
If(fabs(CurrentTemp-MinTemp)<fabs(CurrentTemp-MaxTemp), CurrentTemp-MinTemp, CurrentTemp-MaxTemp)
 
					
				
		
 abhaysingh
		
			abhaysingh
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		sry not working .. i have few combination of temp range
MinTemp MaxTemp Current Temp output by Above logic Getting O/P
-1 5 -1.2 -0.2 -6.2
-40 -18 -17.5 -0.5 0.5
pls suggest
thanks
 rubenmarin
		
			rubenmarin
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		The second case is what you say to Gysbert it should be -0.5
For the first you can change the order of substration:
If(fabs(MinTemp-CurrentTemp)<fabs(CurrentTemp-MaxTemp), MinTemp-CurrentTemp, CurrentTemp-MaxTemp)
 Digvijay_Singh
		
			Digvijay_Singh
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		May be I misunderstood but its appearing like below to me-
As per your definition in the initial details - "Delta is CurrentTemp - MinTemp" so -17.5-(-18) = 0.5.
Also in your first row - Mintemp is 1, Maxtemp is 5, currenttemp is 0.5 so as per your definition it should be 0.5-1=-0.5 but it is showing 0.5 in your table data.
I think you can use Ruben's expression if you want to consider sign else Gysbert's one. In your data there was indication that sign should be ignored while calculating delta. 3rd row should also have -0.2 if you are considering sign and your delta definition.
 
					
				
		
 abhaysingh
		
			abhaysingh
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi Digvijay,
Thanks to correct me i am correcting my self below with desired output..
MinTemp MaxTemp Output
| 1 to 5 | 0.5 | -0.5 | 
| 2 to 5 | 6 | 1 | 
| -1 to 5 | -1.2 | -0.2 | 
| -40 to -18 | -17.5 | 0.5 | 
Please suggest.
Thanks
Abhay
in New to QlikView • Share • Reply • Like (0)
