Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
alidajvr
Contributor
Contributor

Expression consisting of the addition of numeric results of multiple separate nested if-statements

Hi,

I have been struggling with this issue for quite some time, I don't see any topic similar to this on the forum so I'm not sure if this is a bit unorthodox.

I have a couple of nested if-statements which calculate figures.  In another table I need to add up the results of these nested if-statements, but I am unable to get it to work.

I am not able to do these calculations in the script, so I am forced to do it as expressions in tables.

See below my if-statements:

1.  

If(If(If(ReportName='Umlaas',Count(distinct VINNo),0)-Sum(distinct FixedParking)<1,0,If(ReportName='Umlaas',Count(distinct VINNo),0)-Sum(distinct FixedParking))<1,0,
If(If(ReportName='Umlaas',Count(distinct VINNo),0)-Sum(distinct FixedParking)<1,0,If(ReportName='Umlaas',Count(distinct VINNo),0)-Sum(distinct FixedParking))*Max(VariablePrice))

2.

If(If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,0,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo))<1,0,If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,0,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo))*Max(VariablePrice))

3.

=If(If(If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo)<1,0,If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo))<1,0,If(If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo)<1,0,If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo))*Max(VariablePrice))

4.

If(If(If(If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo)<1,If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo),0)+Count({<ReportName={'Pomona 2'}>}distinct VINNo)<1,0,If(If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo)<1,If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo),0)+Count({<ReportName={'Pomona 2'}>}distinct VINNo))<1,0,If(If(If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo)<1,If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo),0)+Count({<ReportName={'Pomona 2'}>}distinct VINNo)<1,0,If(If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo)<1,If((If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo)<1,
(If(Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking)<1,Count({<ReportName={'Umlaas'}>}distinct VINNo)-Sum(distinct FixedParking),0))+Count({<ReportName={'Pomona'}>}distinct VINNo),0)+
Count({<ReportName={'VDS @ Atlas'}>}distinct VINNo),0)+Count({<ReportName={'Pomona 2'}>}distinct VINNo))*Max(VariablePrice))

There are two more, each one longer than the previous.

 

0 Replies