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: 
surajap123
Creator III
Creator III

wrong multiplication result in straight tbl

Hi All,

I have muliplied 2 fields to get final value(TotalHours). When i see the preview in the table viewer, the TotalHours value is correct.

But in the straight table when i did sum, i get wrong result.

Please tell me where i am dong wrong.

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

Your total is not correct in script

Incorrect total.png

Sum(Total) is 2+0. So use sum(U) * sum(Hrs)

View solution in original post

7 Replies
its_anandrjs

Try to get aggregate in the load script like

Temp:

Load

     CourseName,

     units,

     hours,

     (units * hours) as TotalHours

From

[hours multiplication issue.xls]

(biff, embedded labels, table is Sheet2$);

Load

     CourseName,

     units,

     hours,

     Sum(units * hours) as TotalHours

Resident Temp

Group by

     CourseName,

     units,

     hours;

Drop table Temp:

surajap123
Creator III
Creator III
Author

Hi Anand,

Thanks for your reply.

I tried working as you suggested, but its not working.

The issue seems to be the expression used in the straight table.

Here, i am attaching the source and the modified app. Please help !!

anbu1984
Master III
Master III

Add expression sum(U)* sum(Hrs) for Total

anbu1984
Master III
Master III

You get wrong result because

U,Hrs

2,1    --> 2*1=2

1,0    --> 1*0=0

So your total was 2+0=2

surajap123
Creator III
Creator III
Author

Hi Anbu,

Thanks a lot..its working.

I am using set analyis in that expression, so do i need to change the expression from -

=SUM({<Year={'$(vMaxYear)'},Date={'<=$(vMaxDate)'},Month=,Day=,MonthYear=>}Total)

to

=SUM({<Year={'$(vMaxYear)'},Date={'<=$(vMaxDate)'},Month=,Day=,MonthYear=>}Hrs) *

SUM({<Year={'$(vMaxYear)'},Date={'<=$(vMaxDate)'},Month=,Day=,MonthYear=>}U)

Sorry to bother you..but out of curiosity i want to know-

As you can see in the script, i have calculated the 'Total' field as Sum(units * hours), which is giving right result in table viewer.

But in straight table the 'Total' field value is incorrect. Why i need to write expression sum(U)* sum(Hrs)?

anbu1984
Master III
Master III

Your total is not correct in script

Incorrect total.png

Sum(Total) is 2+0. So use sum(U) * sum(Hrs)

anbu1984
Master III
Master III

Yes use the expr

=SUM({<Year={'$(vMaxYear)'},Date={'<=$(vMaxDate)'},Month=,Day=,MonthYear=>}Hrs) *

SUM({<Year={'$(vMaxYear)'},Date={'<=$(vMaxDate)'},Month=,Day=,MonthYear=>}U)