Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
tizianacaem
Partner - Contributor
Partner - Contributor

Problem about expression

hi all,

a question about the synthax of one expression.

I usually write:

sum (if (Year=max (total year) and field1<>0, field1*quantità1, field2*quantità2))

But now i have to calculate this expression not in Max ( total year) but in the year before the Max (total year) es.(year-1).

I thought SetAnalisys was the correct way, but may be i'm wrong, because i can't reproduce the condition of IF.

Anyone can help me please?

Thanks

5 Replies
Not applicable

Hi,

I think this expression should work:

sum (if (Year=(max (total year)-1) and field1<>0, field1*quantità1, field2*quantità2))

tizianacaem
Partner - Contributor
Partner - Contributor
Author

unfortunately it doesn't work!

i suppose SetAnalisys is the right way, but i'm not able to combine

{$<Year = {$(#=Only(Year)-1)}>}

with the condition if...

Any others idea?

thks

Miguel_Angel_Baeyens

Try

{$<Year = {$(#=Only(Year)-1), field = {'<>0'} }>}
for the set analysis including that the field1 value is equal to 0

tizianacaem
Partner - Contributor
Partner - Contributor
Author

ok, but how the expression change from field1 to fiel2 if my condition doesn't occur??

i need that the expression functions in this way:

sum (if (Year=(max (total year)-1) and field1<>0, field1*quantità1, field2*quantità2))

THKS



Miguel_Angel_Baeyens

In that case, you need to use if conditionals anyway, kind of

=If(Year = Max(TOTAL Year) -1 and field1 <> 0, Sum({$<Year = {$(#=Only(Year)-1)}, field = {'<>0'} >} field1 * quantità1), Sum(field2 * quantità2))