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: 
AyCe1082
Creator
Creator

Limiting coordinates on a scatter chart using nested if statements

Hi, I have a working scatter chart that needs to be changed to keep the X coordinates inside a range.

In the screenshot I have a field Event_IDHalf which determines the half in the match and can be 1 or 2. A Direction field which changes per half. The 0 coordinate for X is in the centre in my scatter chart with a range of 4.02 to -4.02. I have to ensure any values that go beyond that is instead showing as the end of the range. I posted a screenshot of my latest attempt at modifying this. I had success earlier with a different version but the - values remained outside the range.

The second part is just the second half and would be a reverse of the first part.

Co-ords.PNG

 

1 Solution

Accepted Solutions
AyCe1082
Creator
Creator
Author

Figured it out. Aside from removing the need for set analysis using the load script, I had to watch out for QV understandably rendering double negatives as a positive.

 

=if(Event_IDHalf='1' or Event_IDHalf='2',

if(Direction='RL',

// if playing towards the left goal
if(if(ShotTargetX>0,-ShotTargetX,ShotTargetX)<-4.02,-4.02,
if(if(ShotTargetX<0,ShotTargetX,-ShotTargetX)>4.02,4.02,
if(ShotTargetX<0,ShotTargetX, -ShotTargetX)))
	  
	  ,
	  
// if playing towards the Right goal	  
if(if(ShotTargetX<0,ShotTargetX,ShotTargetX)<-4.02,-4.02,
if(
	if(ShotTargetX>0,ShotTargetX)>4.02,4.02,
	
	 if(ShotTargetX<0,-ShotTargetX, ShotTargetX)))
	  
	))

I was looking to delete this thread but I saw no option. If it helps someone in future then that's great because this was a nightmare for me! 

View solution in original post

2 Replies
AyCe1082
Creator
Creator
Author

I am able to render anything > 4.02 and anything within the range of 4.02 to -4.02 but anything that is beyond -4.02 doesn't work and keeps its original value.

 

=if(max({<PeriodHalf=>}PeriodHalf)='1',


if(if(maxstring({<Direction2=>}Direction2)='RL',ShotTargetX)>4.02,4.02,
if((if(maxstring({<Direction2=>}Direction2)='LR',-ShotTargetX))<-4.02,-4.02,


if(maxstring({<Direction2=>}Direction2)='RL',ShotTargetX,
if(maxstring({<Direction2=>}Direction2)='LR',-ShotTargetX))))

,

if(max({<PeriodHalf=>}PeriodHalf)='2',


if(if(maxstring({<Direction2=>}Direction2)='RL',-ShotTargetX)<-4.02,-4.02,
if((if(maxstring({<Direction2=>}Direction2)='LR',ShotTargetX))>4.02,4.02,


if(maxstring({<Direction2=>}Direction2)='RL',-ShotTargetX,
if(maxstring({<Direction2=>}Direction2)='LR',ShotTargetX))))

)
)
AyCe1082
Creator
Creator
Author

Figured it out. Aside from removing the need for set analysis using the load script, I had to watch out for QV understandably rendering double negatives as a positive.

 

=if(Event_IDHalf='1' or Event_IDHalf='2',

if(Direction='RL',

// if playing towards the left goal
if(if(ShotTargetX>0,-ShotTargetX,ShotTargetX)<-4.02,-4.02,
if(if(ShotTargetX<0,ShotTargetX,-ShotTargetX)>4.02,4.02,
if(ShotTargetX<0,ShotTargetX, -ShotTargetX)))
	  
	  ,
	  
// if playing towards the Right goal	  
if(if(ShotTargetX<0,ShotTargetX,ShotTargetX)<-4.02,-4.02,
if(
	if(ShotTargetX>0,ShotTargetX)>4.02,4.02,
	
	 if(ShotTargetX<0,-ShotTargetX, ShotTargetX)))
	  
	))

I was looking to delete this thread but I saw no option. If it helps someone in future then that's great because this was a nightmare for me!