Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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
Not applicable

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

Not applicable

Re: conditional field count

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

Not applicable

Re: conditional field count

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