Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum if with a set year

Hi - I have the below expression that is working for a survey results.  The table shows results as below.

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

  I want to show only 2016FY and 2017YTD without users having to select years. The year is called "Completed Year".  Ideally, I want to have the table to look like this.  But I don't think it's possible.   So if you could tell me how I can get to the expression to show just the 2016 without selecting any year filter, that would be a great start for me.

I tried this but of course it doesn't work..

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

Thank you!

16 Replies
Not applicable
Author

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]))

Anonymous
Not applicable
Author

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
Author

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.

Anonymous
Not applicable
Author

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
Author

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
Author

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?  ?_?

Anonymous
Not applicable
Author

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.