Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

toedegaard
New Contributor II

Formula inside IF Statement

Hi all,

How do I do two different calculations within the same expression depending on the value in a field?

I have tried with the calculation below, but it does not work

If( Source = {'Maintenance'}, Sum([Target], Sum(Aggr(Sum(Target) / Count (distinct SC_ID),YearMonth,[Target Component Group],ID)) )

My True and False statements works fine seperately, but not when I am trying to combine it in an IF Statement.

Best regards,

Thomas

3 Replies

Re: Formula inside IF Statement

There is a missing bracket by the first sum(Target) and if-check has a wrong syntax:

If( Source = 'Maintenance', Sum([Target]), Sum(Aggr(Sum(Target) / Count (distinct SC_ID),YearMonth,[Target Component Group],ID)) )

- Marcus

felipedl
Valued Contributor III

Re: Formula inside IF Statement

Hi Thomas,

Try

If( Source = 'Maintenance', Sum([Target]), Sum(Aggr(Sum(Target) / Count (distinct SC_ID),YearMonth,[Target Component Group],ID)) )



felipedl
Valued Contributor III

Re: Formula inside IF Statement

Beat me to it Marcus