Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
joybratas1
Contributor II
Contributor II

If Condition to Set Analysis for multiple Calculation Condition

Hi, 

I tried looking the community, but couldn't find a suitable way to actually use set analysis for multiple IF statements. 

 

I have a scenario for calculating based on conditions like min max and average based on some selections. Is that possible to bring inside a set rather than using this nested loop as it is making my App terribly slow. 

-

=if(vMinMax='MAX' and vTemperature='TEMPERATURE' ,Round(((max({< date_x ={">=$(vStartDate)<=$(vEndDate)"}>}value))-32)*0.5556),


if(vMinMax='MIN' and vTemperature='TEMPERATURE'  ,Round(((avg({< date_x ={">=$(vStartDate)<=$(vEndDate)"}>}value))-32) * 0.5556),
if(vMinMax='MAX', Round(max({< date_x ={">=$(vStartDate)<=$(vEndDate)"}>}value)),
if(vMinMax='AVG' and vTemperature='TEMPERATURE' and vTem=1 ,Round(((avg({< date_x ={">=$(vStartDate)<=$(vEndDate)"}>}value))-32) * 0.5556),

Round(avg({< date_x ={">=$(vStartDate)<=$(vEndDate)"}>}value))

)
)
)
)
))

 

vMinMax= getfieldselections(field) 

vTemperature= getfieldselections (weather) 

 

Any Help is appreciated:) 

Labels (1)
1 Reply
vinieme12
Champion III
Champion III

Set analysis is only for comparing actual fields, not variable values and it does not appear that your fields are meant to be associated to your data

 

You can at best replace this with Pick(Match(

 

=Pick(Match(vMinMax&vTemperature&vTem
,'MAXTEMPERATURE','MINTEMPERATURE','MAX','AVGTEMPERATURE1')+1
,Round(avg({< date_x ={">=$(vStartDate)<=$(vEndDate)"}>}value)) // alternate
,Round(((max({< date_x ={">=$(vStartDate)<=$(vEndDate)"}>}value))-32)*0.5556) // vMinMax='MAX' and vTemperature='TEMPERATURE' and vTem is null

,Round(((avg({< date_x ={">=$(vStartDate)<=$(vEndDate)"}>}value))-32) * 0.5556) //vMinMax='MIN' and vTemperature='TEMPERATURE' and vTem is null

,Round(max({< date_x ={">=$(vStartDate)<=$(vEndDate)"}>}value)) // vMinMax='MAX' and vTemperature is null and vTem is null

,Round(((avg({< date_x ={">=$(vStartDate)<=$(vEndDate)"}>}value))-32) * 0.5556) // vMinMax='AVG' and vTemperature='TEMPERATURE' and vTem=1

)

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.