Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I've an expression in a straight table that calculates the percentage difference in product usage between dates (below):
=NUM(IF((count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)=0 AND count({<DLDate = {'=DLDate>TLDate'}>}DLDate)>0),1,
(count({<DLDate = {'=DLDate>TLDate'}>}DLDate)-
count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))/count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)),'##0%')
This works fine, but I'd like to build a similar expression that counts the number of the above that are greater than 49% and can't work out how to get it going. I'm having trouble getting the count to react to the percentage so any help would be hugely appreciated.
Thanks in advance (and I hope I've explained this correctly!),
Al
=IF(IF((count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)=0 AND count({<DLDate = {'=DLDate>TLDate'}>}DLDate)>0),1,
(count({<DLDate = {'=DLDate>TLDate'}>}DLDate)-
count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))/count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))>0.49,
NUM(IF((count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)=0 AND count({<DLDate = {'=DLDate>TLDate'}>}DLDate)>0),1,
(count({<DLDate = {'=DLDate>TLDate'}>}DLDate)-
count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))/count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)),'##0%'))
That gives me a percentage answer (which in a way is helpful) but I'm looking for a count of the number of results that come back at greater than 49%, rather than a percentage. Thanks in advance!
=IF(IF((count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)=0 AND count({<DLDate = {'=DLDate>TLDate'}>}DLDate)>0),1,
(count({<DLDate = {'=DLDate>TLDate'}>}DLDate)-
count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))/count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))>0.49,
NUM(IF((count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)=0 AND count({<DLDate = {'=DLDate>TLDate'}>}DLDate)>0),1,
(count({<DLDate = {'=DLDate>TLDate'}>}DLDate)-
count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)),
NUM(IF((count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)=0 AND count({<DLDate = {'=DLDate>TLDate'}>}DLDate)>0),1,
(count({<DLDate = {'=DLDate>TLDate'}>}DLDate)-
count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))/count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)),'##0%'))
if, greater than 49%, count, otherwise just show the percentage?
Hi Katarzyna,
That's not quite correct, but nearly there - the best way to put it would be:
If greater than 49%, count, otherwise do not count.
Cheers,
Al
Try this Alex:
=IF(IF((count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)=0 AND count({<DLDate = {'=DLDate>TLDate'}>}DLDate)>0),1,
(count({<DLDate = {'=DLDate>TLDate'}>}DLDate)-
count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))/count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))>0.49,
NUM(IF((count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)=0 AND count({<DLDate = {'=DLDate>TLDate'}>}DLDate)>0),1,
(count({<DLDate = {'=DLDate>TLDate'}>}DLDate)-
count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)),
null()
)
There's an error in the expression somewhere there - we're nearly there though!
try this:
IF(IF((count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)=0 AND count({<DLDate = {'=DLDate>TLDate'}>}DLDate)>0),1, (count({<DLDate = {'=DLDate>TLDate'}>}DLDate)-count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))/count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))>0.49,
IF((count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate)=0 AND count({<DLDate = {'=DLDate>TLDate'}>}DLDate)>0),1,(count({<DLDate = {'=DLDate>TLDate'}>}DLDate)-count({<DLDate = {'=DLDate<TLDate and DLDate>TLDate-30'}>}DLDate))),
null()
)
That's brilliant and seems to work great but I'm getting higher results than I was expecting. In Excel I have a formula that calculates the percentage and another that references it thus: =IF([percentage cell]>49%,"1","0"). I simply sum this column to give me the total number of instances over 49%.
It was my understanding that if I counted the instances over 49% in my Qlik expression this would give the same result but it's not working out that way - is this the correct approach?
maybe you could post a sample dashboard?