Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
raadwiptec
Creator II
Creator II

if stmt

I need to have something in the script like the below -

IF len (product) < 0 and isnull(product) then costprice else saleprice

any suggestions

10 Replies
raadwiptec
Creator II
Creator II
Author

IF len (product) < 0 and isnull(product) then costprice else saleprice as  PRODUCT PRICE

PrashantSangle

Hi,

try like

if(len(trim(product))=0,costprice,saleprice)

In this case you dont required to test isnull()

Regards,

Prashant

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 🙂
PrashantSangle

len(product) < 0 ????

Can you give example of this case???

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 🙂
Anil_Babu_Samineni

May be this?

If(Len(Product) = 0, If(IsNull(Prodcut), Sum(costprice), Sum(saleprice)))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
raadwiptec
Creator II
Creator II
Author

MEXAMPLE -- MY PRODUCT data goes something like this MFELKAB etc..

so in many cases my source is blank or null. So i need to check both conditions i.e product shows as blank or - (null)

PrashantSangle

Hi,

- does not indicate null.

You can write like

If(len(trim(fieldName))=0 or trim(fieldName)="-",costPrice,SalesPrice)

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 🙂
raadwiptec
Creator II
Creator II
Author

all the above is only working for len .. for null part it is not working i tried both isnull and trim(product) = '-'

Anil_Babu_Samineni

Will you provide few rows related the combination of data and better if you provide expected result

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
PrashantSangle

Hi,

If there is space in field then isnull() wont work.

So you have to use len(trim(product))=0

If this wont help you then provide some sample data or share your screen shot of what you tried.

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 🙂