Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Modify and calculate loaded data?

Hi everyone,

I'm a bit new to Qlikview, but I'm wondering if there is possible to work with the data i load, for example, if I load, data from to tables can I then in Qlikview calclulate, ex. amount = 12 and time = 2 and do 12/2 = 6 and then display 6. and so on?

Or do i need to make all calculations, modifications and so before loading it in to qlikview?

thanks in advance!

18 Replies
alexandros17
Partner - Champion III
Partner - Champion III

You can do it in Script and in objects in lots of ways

its_anandrjs
Champion III
Champion III

Yes you can do this

LOAD *,amount/time as Division;

LOAD * Inline

[

amount,time

12,2

];

And then take table box and add fields amount , time , Division

and also in front end you can calculate this values there are many ways.

Not applicable
Author

thx!

just one more thing.. I have timestamps as an integer in minutes after midnight, for example. 432 is 432 minutes after midnight, ( 0.00 ) i need to convert this to time. which in this case will be 07:12

in php i can do it like this:

function tm($nm, $lZ = true){

  $mins = $nm % 60;

  if($mins == 0)    $mins = "0$mins";

  $hour = floor($nm / 60);

  if($lZ){

    if($hour < 10) return "0$hour:$mins";

  }

  return "$hour:$mins";

}

echo tm(432);

Can i use php scripts in qlikview? or how do i do this?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Divide by 60*24 and you'll have the fraction of a full day. You can show that as a time: time(MyTimeStamp/1440,'h:mm')


talk is cheap, supply exceeds demand
Not applicable
Author

where do i use this? as an expression or where do i define that to an variable?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Whereever you need it. It's an expression. You can use it to create a new field in the script:

MyTable

load *, time(MyTimeStamp/1440,'h:mm') as MyNewField

from MySource;

Or in a chart expression, or in a variable that you then later use in an expression.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi again!

If i want to use loaded data from two loads in a new load to do a calculation. se example:

timestart:

LOAD

    time(P_TIME/1440,'hh:mm') AS timestart,

Resident punches

Where P_TYPE=1;

timeend:

LOAD

    time(P_TIME/1440,'hh:mm') AS timeend,

Resident punches

Where P_TYPE=2;

and then i want to take timeend/timestart AS totaltime  to se the time lapse.

How do i do this?

PrashantSangle

Hi,

Looking at your script,

You can do the above thing in one table.

Like

Try this.

In your original table Which is i think punches write below code.

    If(P_TYPE=1,time(P_TIME/1440,'hh:mm')) AS timestart,

    If(P_TYPE=2,time(P_TIME/1440,'hh:mm')) AS timeend,

Then performed

Load

     timeend/timestart AS totaltime

Resident punches


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 🙂
Not applicable
Author

I try this but not succesfull... i do get  timeend undefined.

punches:

LOAD

     P_DATE AS date,

     P_TIME,

     P_TYPE,

     If(P_TYPE=1,time(P_TIME/1440,'hh:mm')) AS timestart,

     If(P_TYPE=2,time(P_TIME/1440,'hh:mm')) AS timeend

FROM

[.....Punches.qvd]

(qvd);

Load

     timeend/timestart AS totaltime

Resident punches

dont i need any type of else statement ?