Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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.

1 Solution

Accepted Solutions
Jason_Michaelides
Luminary Alumni
Luminary Alumni

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

View solution in original post

3 Replies
Not applicable
Author

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?

Jason_Michaelides
Luminary Alumni
Luminary Alumni

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

Not applicable
Author

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