Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with Sum and variables

Hi,

I have the following sum which works:

=Num(sum({<[Year]={$(vCurrentYear)}>}[Hours Worked]*if(IsNull(Rate), 20, Rate)), '£#,##0;(£#,##0)')

What I can't figure out is to add the equivelent of an AND in.

=Num(Sum({<[Year]={$(vCurrentYear)}>} and If(Not([Project Status]='Admin'), [Hours Worked]*if(IsNull(Rate), 20, Rate))), '£#,##0;(£#,##0)')

I was thinking of something like the above, but that just gives a '-' in the result. Any help would be appreciated.

Thanks

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Didn't count the '(' and ')' 's. Try:

=Num(Sum({<[Year]={$(vCurrentYear)}, [Project Status] -={'Admin'}>} [Hours Worked]*if(IsNull(Rate), 20, Rate)), '£#,##0;(£#,##0)')


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

Try:

=Num(Sum({<[Year]={$(vCurrentYear)}, [Project Status] -={'Admin'}>} [Hours Worked]*if(IsNull(Rate), 20, Rate))), '£#,##0;(£#,##0)')


The expression editor doesn't know yet that -= is correct syntax, but that's a bug in the editor so don't worry about the red underlining.


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks Gysbert, pasted it in and it's showing '-', so that didn't work unfortunatly.

The editor didn't underlinethe -= , however, it did on the folling {

Gysbert_Wassenaar

Didn't count the '(' and ')' 's. Try:

=Num(Sum({<[Year]={$(vCurrentYear)}, [Project Status] -={'Admin'}>} [Hours Worked]*if(IsNull(Rate), 20, Rate)), '£#,##0;(£#,##0)')


talk is cheap, supply exceeds demand
Not applicable
Author

Perfect, thank you