Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ashokunbi
Contributor III
Contributor III

Join 2 if statements in expression

I have two if statements in one expression, each works by itself but don't work when combined. I have similar expressions that work just fine by joining the 2 if statements with a +,  e.g.

if(Quarter='Q4 CY 2018',Sum(Aggr(if(TransMonth='Oct',1-(IssuesPOs/TotalPOs),0), TransMonth)),Sum(Aggr(if(TransMonth='Jul',1-(IssuesPOs/TotalPOs),0), TransMonth)))+
if(Quarter='Q1 CY 2019',Sum(Aggr(if(TransMonth='Jan',1-(IssuesPOs/TotalPOs),0), TransMonth)),Sum(Aggr(if(TransMonth='Oct',1-(IssuesPOs/TotalPOs),0), TransMonth)))

But the one below doesn't work even though it says expression OK:

IF(Quarter='Q4 CY 2018',Avg({<TransMonth = {'Oct'}>}CEScore),Avg({<TransMonth = {'Jul'}>}CEScore))+
IF(Quarter='Q1 CY 2019',Avg({<TransMonth = {'Jan'}>}CEScore),Avg({<TransMonth = {'Oct'}>}CEScore))

I have tried using  a comma instead of the plus sign and tried different things but nothing works but each if statement works fine on it's own. Help would be very much appreciated.

 

 

Labels (1)
2 Replies
Sergey_Shuklin
Specialist
Specialist

Hello!
Try to cover each IF in dollar-sign-parentheses, it will calculate each one into a value and then you should get a sum of them. Like this:
$(=IF(Quarter='Q4 CY 2018',Avg({<TransMonth = {'Oct'}>}CEScore),Avg({<TransMonth = {'Jul'}>}CEScore)))
+
$(=IF(Quarter='Q1 CY 2019',Avg({<TransMonth = {'Jan'}>}CEScore),Avg({<TransMonth = {'Oct'}>}CEScore)))
PrashantSangle

Can be more specific about meaning of not working?
Is it giving you wrong output? or
Not giving you any output at all?
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂