Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.


Count of values in the field and Average

I have data in the below given format.


TypeCategoryTransactionDate                         Bank                  In Date        Out DatePatternDescription
ABC CreditDeposit9/23/2018      11111
ABC DebitWithdrawal9/23/2018 11
XYZCreditDeposit9/23/2018 11111
XYZDebitWithdrawal9/23/2018 11
AAA DebitWithdrawal9/23/2018 11
AAA CreditDeposit9/23/2018 11111
ADebitWithdrawal9/23/2018 11

I need to enable the user to select the filters on Type, Category, Transaction, and Date and based on the selections, I need to check if the subsequent fields have '1' in the values. After that, I need to sum them up and find the average by number of fields.

For example, if the user selects Type - ABC, Category - Credit, Transaction - Deposit , Date - 9/23/2018, I need to count how many fields have '1' in them and find the average as below.

5 (1 for Bank, 1 for In Date, 1 for Out Date, 1 for Pattern and 1 for Description) / 5 (Since there are 5 fields) =1

If the user selects none, it should count number of '1's in all the 5 fields divided by number of fields, which is 5.

2 Replies

Re: Count of values in the field and Average

If I understand your request correctly, you could transform your table from a crosstable to a straight table using

The Crosstable Load

Something like

CROSSTABLE (FlagField, Flag, 4)

LOAD Type, Category, ..... // all other fields like shown above

FROM YourTable;

Then your count could look like

=Count({<Flag = {1}>} DISTINCT FlagField) / Count(DISTINCT FlagField)


Re: Count of values in the field and Average

Thank you Stefan! I will give this a shot