Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with a new field

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

9 Replies
Not applicable
Author

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
Author

Here is an example of what I mean.

diegofcaivano
Partner - Creator
Partner - Creator

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
Author

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
Author

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
Author

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.

MayilVahanan

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,

];

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

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
Author

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?