Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bentley32
Contributor
Contributor

If doesn't give the same result then set

hello all,

why this : 

 

sum({< m_since_reg = {">=0"} , principal= {">=$(=Min strat montant)"},principal= {"<=$(=Max strat montant)"},age_dossier= {">=$(=Min strat age)"},age_dossier= {"<=$(=Max strat age)"} >} enc_m0)

 

give a different result then this : 

sum(if(m_since_reg>=0 and (principal)>=$(Min strat montant)and (principal)<=$(Max strat montant)and (age_dossier)>=$(Min strat age) and (age_dossier)<=$(Max strat age), enc_m0 ))

 

Thanks

 

2 Replies
tresesco
MVP
MVP

Set analysis and If structure are not synonymous. They produce same results in less number of scenarios than different. So context is very important to understand and investigate the 'why' they are not generating same results which is more common I would say. 

- data model

- chart context (dimensions) or KPI object

These are very important to know. Try to share a sample qvf to investigate and help.  

marcus_sommer

Beside the already mentioned context of a calculation there is a general difference between an if-loop and a set analysis. All conditions within an if-loop are checked on a row-level while a "classical" set analysis performed this task on a column-level and is therefore usually much faster as an if-loop. But if you need a row-level comparing you will need if-loop-approaches.

Beside this are your expressions not equally because the if-loop used "simple" variables and the set analysis applies a double $-sign expansion and creates an adhoc-variable. Depending on the variable-content the results could be different.

- Marcus