Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
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
MVP & Luminary
MVP & Luminary

Re: conditional field count

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

Highlighted
Not applicable

Re: conditional field count

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

Highlighted
Not applicable

Re: conditional field count

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