Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
dmac1971
Creator III
Creator III

# Months Over Target

I have a calculation that checks % records meeting target by month.  This works well but as an additional col in a straight table I want to show the total # months the target was achieved.

Using examples online I have this :

Count(DISTINCT if( only(aggr( count({<RES = {'Y'}>} RecordID) / count(RecordID),Month) >= 0.83),Month))

However its not working.  Any ideas?  83% is target.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try removing the Only():

Count(DISTINCT if( (aggr( count({<RES = {'Y'}>} RecordID) / count(RecordID),Month) >= 0.83),Month))

View solution in original post

9 Replies
swuehl
MVP
MVP

Try removing the Only():

Count(DISTINCT if( (aggr( count({<RES = {'Y'}>} RecordID) / count(RecordID),Month) >= 0.83),Month))

sunny_talwar

May be this:

Sum(Aggr(If(Count({<RES = {'Y'}>} RecordID) / count(RecordID),Month) >= 0.83, 1, 0), Month))

Anonymous
Not applicable

may be like this?

=Count(DISTINCT if((aggr( count({<RES = {'Y'}>} RecordID) / count(RecordID),Month) >= 0.83),Month))



dmac1971
Creator III
Creator III
Author

Works great for the overall result, many thanks, however I also have product category, lets say "ProdCat" dimensions and the results are wrong for these in the table, I assume I need to add this dimension into the calculation as well?

swuehl
MVP
MVP

Try something like

Count(DISTINCT Aggr(If(Count({<RES = {'Y'}>} RecordID) / count(RecordID),Month) >= 0.83, Month), Month, ProdCat))

dmac1971
Creator III
Creator III
Author

OK this works but the result is 1 greater than it should be.  Now I could just add -1 and get the right answer but wonder why its one greater than it should be?  Thanks for all replies by the way!!

(DISTINCT if((aggr( count({<SOT? = {'Y'}>} RecordID) / count(RecordID),Month,ProdCat) >= 0.83),Month,ProdCat)) 

swuehl
MVP
MVP

What is the last line showing? That's not what I suggested.

dmac1971
Creator III
Creator III
Author

Last line is showing 74 with your suggestion, plus the individual dimension results are incorrect.  When I alter it to what I posted it shows 78, however the individual dimension results are correct, albeit over by 1?  Again thanks.

swuehl
MVP
MVP

Well, hard to answer with the information provided. If possible, create and upload a small sample QVW.