Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If a value ends with a certain two figures

Hi,

I am new to Qlikview. I have a list or order numbers. The orders that end in an 81 are those that belong to a specific product type (type a)

45615

123

7894

581

44781

75984

4581

I would like to use an IF function to return those order numbers that end in 81 to be highlighted as 'type a' and the others as 'type b'.

Can you help please?

Thanks

4 Replies
Anonymous
Not applicable
Author

This can be done in the load script. For example:

Orders:

Load * Inline [

Order, Product

1,101

2,102

3,181

4,282

];

OrdersWithFlag:

Load

    *,

    If (Right (Product,2)='81','Type A','Type B') as IsTypeAProduct

Resident Orders;

Drop Table Orders;

Table OrdersWithFlag will contain both the original product an indicator for product type (which here I've called IsTypeAProduct).

Loading the flag in the script may be the easiest in that it creates a flag that you can reference all throughout your document without having to rewrite the formula each time.

You can also add the above formula, for example, as an expression in a straight table chart (sans 'as IsTypeAProduct'), and it'll work. This may be the better solution if you don't want to mess with the script or only need the indicator in one or two place. The straight table will look like this:

20151030_1.GIF

settu_periasamy
Master III
Master III

Hi,

Try like

If (right (yourfield,2)=81,'Type A','Type B') as [Product Type]

PrashantSangle

Hi,

Another option could be using match() and wildmatch()

like

if(wildmatch(fieldName,'*81'),'Type A','Type B') as Product_Type

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Kushal_Chawda

create a field in script like

if(FieldName like '*81','Type a','Type b') as Product _Type