thebusiness11
thebusiness11

Reputation: 521

Qlik Sense IfNum combined with If Statement

I am attempting to run a an AVG on a Column where a number exists and that number is greater than 0, the column has mixed data, most fields will have a number but a few credit results come back NA or DNR.

The following expression, checks out as OK but doesn't return any values. I know the AVG expression works correctly as I have used it on clean data. I believe the error is coming from the IsNum

=if(IsNum(Credit) = '-1', Avg({< [Credit] = {"<>0"} >} [Credit]), (Credit))

Upvotes: 0

Views: 1255

Answers (1)

Stefan Stoychev
Stefan Stoychev

Reputation: 5012

Probably is better to create additional column, in your script, indicating if the Credit value is number or not.

if( isNum(Credit), 1, 0 ) as isNumberCredit

After this your expression became simple.

avg( {< isNumberCredit = {1} >} Credit )

OR

avg( Credit * isNumberCredit )

Using this approach will decrease the performance in bigger data sets.

Upvotes: 1

Related Questions