Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Re: Sum if with a set year

Actually I did the following for NPS.... It spits out a reasonable number... Is this correct or can it be simplified?  Thanks..

100*count({<[Would Recommend]={'Yes'}, [Completed Year]={2016}>} [Would Recommend])/count({<[Completed Year]={2016}>} [Would Recommend])-(100*count({<[Would Recommend]={'No'}, [Completed Year]={2016}>} [Would Recommend])/count({<[Completed Year]={2016}>} [Would Recommend]))

mov
Esteemed Contributor III

Re: Sum if with a set year

Looks fine to me.  It could be a little bit simplified, not much.  E.g., as if you have

100*A/C - 100*B/C

can be replaced with

100(A-B)/C

But it's fine to keep as is, of course.

And, since you have a dimension now in your table (Region), you don't need my qvf anymore.  It is specifically for the "no-dimension" situation.

Not applicable

Re: Sum if with a set year

Michael - I got everything else to work including var. and background color expressions, BUT, the very 1st expression for Recommend actually doesn't give the correct #.  The result of the original expression I had below for 2016 would have been 94.7.  They are always in the 90's.

100*Sum(IF([Would Recommend]='Yes',1,0))/Sum(IF([Would Recommend]='Yes' or [Would Recommend]='No',1,0))

The expression you did with 2016 below gives 89.5.

100*count({<[Would Recommend]={'Yes'}, [Completed Year]={2016}>} [Would Recommend])/count({<[Completed Year]={2016}>} [Would Recommend])

I'm really not sure what could be causing this because I did all other categories in the way you did and they all give correct #s. Just this one. Please take another look? ;_;  Thank you so much.

mov
Esteemed Contributor III

Re: Sum if with a set year

As I've said at the beginning, there maybe something about you data that I can't guess.  For example, there could be [Would Recommend] values other than 'Yes' and 'No'.  If this is the case, this will help:


100*count({<[Would Recommend]={'Yes'}, [Completed Year]={2016}>} [Would Recommend])/count({< [Would Recommend]={'Yes','No'}, [Completed Year]={2016}>} [Would Recommend])


If this doesn't help, I'm out of guesses.  You can either upload your app to help me to find the reason, or reverse back to sum(), with some modifications:

100*Sum({<[Completed Year]={2016}>} IF([Would Recommend]='Yes',1,0))/Sum({<[Completed Year]={2016}>} IF([Would Recommend]='Yes' or [Would Recommend]='No',1,0))

Not applicable

Re: Sum if with a set year

I did the below and seems to be working.  I think mine just could be simplified and yours is the simplified version.  Thank you!

100*count({<[Would Recommend]={'Yes'},[Completed Year]={2016}>} [Would Recommend])/Sum(IF([Would Recommend]='Yes' and [Completed Year]='2016' or [Would Recommend]='No' and [Completed Year]='2016',1,0))

Not applicable

Re: Sum if with a set year

Now the management wants to do a trend by month current year compared to prior year.  Is there a way to do this not for the entire year but for Jul-17 and the same for Jul-16?  ?_?

mov
Esteemed Contributor III

Re: Sum if with a set year

You can add Month condition to the set analysis, or replace the Year condition with MonthYear.  Can't tell more without knowing your data fields.
More important - since it is a new question,it is better to open a new discussion.  I'm rather busy, and other people typically not going to look at the closed discussions.