Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

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

Help with a new field

...............

9 Replies
Not applicable

Re: Help with a new field

You can create a new field in the script using a wildmatch function like this:

If(WildMatch(Title,'*Autumn*'),'Autumn',

If(WildMatch(Title,'*Spring*'),'Spring',

If(WildMatch(Title,'*Summer*'),'Summer',

If(WildMatch(Title,'*Winter*'),'Winter','None')))) as Term

Then you can use the field Term as a list box like usual.

Not applicable

Re: Help with a new field

Here is an example of what I mean.

diegofcaivano
Contributor

Re: Help with a new field

Hi. I would use a combination of PICK() function along with WILDMATCH() -as rebeccad correctly said- to get it.

PICK(WILDMATCH(Title, '*autumn*', '*spring*', '*summer*', '*winter*'), 'Autumn', 'Spring', 'Summer', 'Winter') AS Term

Same result, just a little cleaner code if you have more values to compare.

Regards.

Not applicable

Re: Help with a new field

Thats great guys thanks for the replies. i dont think it will work tho as there are around 200 fields, and within the fieldnames of these 200 fields it will include the 'Term' (autumn, Summer ect). so i will need the new 'Term' field to look at all of these 200 fields.

Does that make sense?

Not applicable

Re: Help with a new field

The inline load was just an example.  When you add it to your script and use the equation against whatever your field name is, it will look at every field, no matter how many you have.  If you have a sample file, it would be easier for Diego and I to show you what we mean.

Not applicable

Re: Help with a new field

Rebeccad,

in your example..

Data:
LOAD * INLINE [
    Title
    PupilResultsY1AutumnReadingAPS,
    PupilResultsY1AutumnWritingAPS,
    PupilResultsY1AutumnMathematicsAPS,
    PupilResultsY1AutumnScienceAPS,
    PupilResultsY1AutumnICTAPS,
    PupilResultsY1SpringReadingAPS,
    PupilResultsY1SpringWritingAPS,
    PupilResultsY1SpringMathematicsAPS,
];

Seasons:
LOAD *,
If(WildMatch(Title,'*Autumn*'),'Autumn',
If(WildMatch(Title,'*Spring*'),'Spring',
If(WildMatch(Title,'*Summer*'),'Summer',
If(WildMatch(Title,'*Winter*'),'Winter','None')))) as Term
Resident Data;
DROP Table Data;

the lines   PupilResultsY1SpringReadingAPS,etc are field names not values within a field. so where you have the field name of Title, and then the data under it. its the data under it hat are my field names.

Re: Help with a new field

HI

Try like this

LOAD *,PICK(WILDMATCH(Title, '*autumn*', '*spring*', '*summer*', '*winter*'), 'Autumn', 'Spring', 'Summer', 'Winter') AS Term  INLINE [

    Title

    PupilResultsY1AutumnReadingAPS,

    PupilResultsY1AutumnWritingAPS,

    PupilResultsY1AutumnMathematicsAPS,

    PupilResultsY1AutumnScienceAPS,

    PupilResultsY1AutumnICTAPS,

    PupilResultsY1SpringReadingAPS,

    PupilResultsY1SpringWritingAPS,

    PupilResultsY1SpringMathematicsAPS,

];

Not applicable

Re: Help with a new field

Hi All

attached is a sample of data.as you can see there are a lot of fields with the 'Term' incorporated into the fieldnames.

I want to create a new field called 'Term' and i want to be able to select 'Summer' (for example) and see all the data related to 'Summer'.

Does that make sense?

Not applicable

Re: Help with a new field

I see what you mean.  Unfortunately that makes it a lot harder.  I have attached an example in which I used conditional layouts to show the relevant column headers based on season selection. However, this may not be feasible for you if you have so many.  Maybe someone else on the forum will have a better solution?

Community Browser