Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

conditional field count

Hi everyone!

What I am trying to achieve is to wildcard match from all loaded fields and select those which have particular value. This matched fields will have only one value assigned all the time.

my script will bring you closer to what I want to do, but its obviously not working

let maskedCount = 1;

for Each maskedField in WildMatch([$Field],'mask_*')

  if Num(maskedField) <> -1 then

    let $maskedCount = $maskedCount + 1;

  ENDIF

NEXT maskedField;

can you, please, show me an elegant way to do this?

Thank you all!

3 Replies
marcus_sommer

I think you need another approach with table- and field-functions - $Field isn't available in script. See here a small example to count fields:

for i = 0 to NoOfTables() - 1

    for ii = 1 to NoOfFields(TableName($(i)))

        let vTableName = '[' & TableName($(i)) & ']';

        let vFieldName = '[' & FieldName($(ii), TableName($(i))) & ']';

        for j = 0 to NoOfTables() - 1

            for jj = 1 to NoOfFields(TableName($(j)))

                let vFieldNameCounter = '[' & FieldName($(jj), TableName($(j))) & ']';

                let vFieldCounter = if('$(vFieldName)' = '$(vFieldNameCounter)', 1 + $(vFieldCounter), $(vFieldCounter));

            next

        next

     next

next

- Marcus

Not applicable
Author

Hi Marek, there is no $Field field in the script level. Please go with what Marcus suggested.

Not applicable
Author

thank you, guys! actually, it was easier for me cause I have to iterate through one table only...