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

% incorrect

Dear sir,

I am trying to calculate percentage from script but its showing wrong value.

can you help me to resolve it.

below is the script and screen shot of the  output.

Load

'1' as Dom_PL_HCount,

Month(Booking_Date_All) as dom_TMonth,

Year(Booking_Date_All) as dom_TYEAR,

Gross_Sales_NonAir as dom_b2b2

Resident Ezeego where [Flag Air/Non-Air]='Non-Air' and Source='B2B' and [Flag International/Domestic]='Domestic';

Concatenate(dom_actual1)

Load

'5' as Dom_PL_HCount,

Month(Booking_Date_All) as dom_TMonth,

Year(Booking_Date_All) as dom_TYEAR,

Income as dom_b2b2

Resident Ezeego where [Flag Air/Non-Air]='Non-Air' and Source='B2B' and [Flag International/Domestic]='Domestic';

Concatenate(dom_actual1)

Load

'8' as Dom_PL_HCount,

dom_TMonth,

dom_TYEAR,

sum(if(Dom_PL_HCount='5',dom_b2b2))/sum(if(Dom_PL_HCount='1',dom_b2b2)) as dom_b2b2

resident dom_actual1 group by dom_TMonth,dom_TYEAR;

7 Replies
nishanthi_8
Creator
Creator

What is the expression you are using in this ?

pranali_gawde
Partner - Contributor III
Partner - Contributor III
Author

sum(dom_b2b2)

nishanthi_8
Creator
Creator

What is the pupose of concatenating with the original table and again taking resident of it? This might also lead to improper values. Try this , concatenate the table which contains " '8' as Dom_PL_HCount" field and then take resident of  " dom_actual1" and try your calculation.

sunilkumarqv
Specialist II
Specialist II

Can you try use below expression

if(Dom_PL_HCount='8',num#(sum(dom_b2b2),'#,#0% ;'),sum(dom_b2b2))

pintucs20
Contributor III
Contributor III

Hi Pranali,

If you want a result set in percentage% use Aggregate functions in Expression instances of a script.

If you want use only in script , then use preceding load in script and aggregate data first and do , what you want result set according ?

can you share excel sheet  with expected Output?

pranali_gawde
Partner - Contributor III
Partner - Contributor III
Author

Thank you so much all for your quick reply. I Ressolved the  Problem .

balabhaskarqlik

Share the solution, to make it useful to others.

And make it as Answered, close this thread.