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

How to perform division operation in script side

Hi Everybody,


my script is like below


sale:


LOAD Name,

Prd.Cat.No,

Sales,

'bill' as Category

FROM

(ooxml, embedded labels, table is Sheet1) where Prd.Cat.No =101;

Concatenate

LOAD Name,

Prd.Cat.No,

Sales,

'book' as Category

FROM

(ooxml, embedded labels, table is Sheet1) where Prd.Cat.No =102;


so i want to create one another table which is category type as   "book / bill"



which is like



LOAD Name,

Prd.Cat.No,

Sales,

'book / bill' as Category

FROM

(ooxml, embedded labels, table is Sheet1) ;



How it is possible in script ?????????


Thanks in Advance.





17 Replies
Anil_Babu_Samineni

Can you try this?

Sample:

LOAD * INLINE [

    Name, Prd.No, Sales

    abc, 101, 120

    xyz, 101, 180

    pqr, 101, 270

    abc, 102, 30

    xyz, 102, 60

    pqr, 102, 90

];

Final:

NoConcatenate

load Prd.No, Sum(Sales) as Sales, 'Bill' as Category

Resident Sample Where Prd.No = 101 Group By Prd.No;

load Prd.No, Sum(Sales) as Sales, 'Book' as Category

Resident Sample Where Prd.No = 102 Group By Prd.No;

DROP Table Sample;

Last:

NoConcatenate

LOAD Sales, Prd.No, Category Resident Final;

Concatenate

LOAD Prd.No, 'Bill/Book' as Category, If(Prd.No = 101,Sum(Sales))/If(Prd.No = 102,Sum(Sales)) as Sales Resident Final Where Prd.No = 101 and Prd.No = 102 Group By Prd.No;

DROP Table Final;

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

You can create flag using if condition also. Try below

Sample:

LOAD Name,Prd.No,Sales,if(Prd.No=101,'Bill','Book') as Flag,if(Prd.No=101,Sales) as BillSales,if(Prd.No=102,Sales) as BookSales INLINE [

    Name, Prd.No, Sales

    abc, 101, 120

    xyz, 101, 180

    pqr, 101, 270

    abc, 102, 30

    xyz, 102, 60

    pqr, 102, 90

];

concatenate

Load 'Bill/Book' as Flag,Sum(BillSales)/Sum(BookSales) as sales_div Resident Sample;

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

Are you sure, this will return 'Bill/Book' ?? I wonder, This may returns null()

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

Yes..

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 🙂
chinnuchinni
Creator III
Creator III
Author

for bill/book it's giving value as Zero

PrashantSangle

PFA.

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 🙂
chinnuchinni
Creator III
Creator III
Author

bill_book.PNG

PrashantSangle

In your earlier reply you are taking category as dimension. So logic is as per category field.

Replace Name field with Flag You will get desired result.

See below snap shot for your reference.

Capture.PNG

If it is not solving your requirement , mention what is your actual and complete requirement.

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 🙂