3 Replies Latest reply: Apr 8, 2012 4:30 AM by Göran Hofstedt

# How to do calculation in qv?

Hi

I´m not sure how to do this but hope some can help me.

I have the following fields with data: Timeunit that are either "day", "week" or "month". Time that are a number. Periodicity that are a number.

Then I have seven diffrent fields that have "J" in them if true. (if time are set to occur on monday, monday=J, and so on for the diffrent days)

I want to do the following (in script if it´s poosible)

If timeunit are week, Time / Periodicity

If timeunit are month, (Time / Periodicity) /4,33

If timeunit are day, (number of J * Time) / Periodicity

(As for number of J, max 7 - how to make qlikview "count" number of J, and if their ain´t any markes of J, will qv count 0? If so, I have to make it count 1 because 0 ' xy will return 0 and thats wrong?)

I attach I small sample of data in xls.

• ###### How to do calculation in qv?

Ok. I have got the calculation as a if(expression) that works for periodicity with week and months but when it´s days the if statemeant becomes...difficult..

If(TimeUnit ='Day' AND Monday='J' AND Tuesday='J' AND Wednesday='J' AND Thursday='J' AND Friday='J' AND Saturday='J' AND Sunday ='J' , sum((('7'*DecimalTime)*'4,33')/Periodicity))

And that´s only for one combination...

Can someone help me to make it in a better way? Can I somehow convert it to a table or something?

• ###### Re: How to do calculation in qv?

Hi,

Please see attached for one solution.  Not sure what your "Time" field was so I used Hours but you can substitute for whatever you want.

Hope this helps,

Jason

• ###### How to do calculation in qv?

Thnks! the timeformat is the same as the one you helped me out with in previous post so I will apply that solution on this but I´m sure that won´t be any problem