Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Help: How to multiply??

I want to calculate cubic space (width * height * length).

so here i have measurements for width, height and length.

what is the expression for cubic space???

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Help: How to multiply??

(sum(width) * sum(length) * sum(height))/1728 as CubicSpace

To begin with this is probably not calculating what you want. It first sums all the lenghts, all the widths and all the heights and than multiplies the sums. This is something completely different from sum( widht*length*height).

Next if you use an aggregation function like sum, you need to use the group by clause. Your load script would look like this:

Temp:

SQL SELECT width,

   length,

   height,

   OrderNo

FROM CourierComplete.dbo.CompletedOrderPackages;

CompletedCubicMeasure:

load OrderNo, (sum(width) * sum(length) * sum(height))/1728 as CubicSpace

resident Temp group by OrderNo;

drop Table Temp;


talk is cheap, supply exceeds demand
8 Replies
MVP & Luminary
MVP & Luminary

Re: Help: How to multiply??

It's width * height * length if your field names are 'width', 'height' and 'length':

load

object, width, height, length,

width * height * length as cubic_space

from ...somewhere;


talk is cheap, supply exceeds demand
MVP
MVP

Re: Help: How to multiply??

If you do have records that contain your measures, maybe like this

LOAD *,

width*height*length as CubicSpace

INLINE [

room, width, height, length

A, 10, 20, 30

B, 5,8,7

];

Not applicable

Re: Help: How to multiply??

CompletedCubicMeasure:

load

*,

width,

length,

height,

OrderNo,

width * Length * Height as CubicSpace;

SQL SELECT

  *

FROM CourierComplete.dbo.CompletedOrderPackages;

this is my code, but it was returned with error. can you please tell me where i made the mistake at?

Not applicable

Re: Help: How to multiply??

hi, i dont understand anything after inline

INLINE [

room, width, height, length

A, 10, 20, 30

B, 5,8,7

];

can you please tell me what this is, and what is room and those numbers???

MVP & Luminary
MVP & Luminary

Re: Help: How to multiply??

You will get an error that field names must be unique. The * loads all field names. You then load width, lenght, height and OrderNo again without renaming them.


talk is cheap, supply exceeds demand
Not applicable

Re: Help: How to multiply??

Hi Gysbert,

     i am trying to sum up all the width and multiply by all the length, and so on, but my equation shows oledb failed...

my Code:

CompletedCubicMeasure:

load

(sum(width) * sum(length) * sum(height))/1728 as CubicSpace,

*;

SQL SELECT width,

   length,

   height,

   OrderNo

FROM CourierComplete.dbo.CompletedOrderPackages;

MVP & Luminary
MVP & Luminary

Re: Help: How to multiply??

(sum(width) * sum(length) * sum(height))/1728 as CubicSpace

To begin with this is probably not calculating what you want. It first sums all the lenghts, all the widths and all the heights and than multiplies the sums. This is something completely different from sum( widht*length*height).

Next if you use an aggregation function like sum, you need to use the group by clause. Your load script would look like this:

Temp:

SQL SELECT width,

   length,

   height,

   OrderNo

FROM CourierComplete.dbo.CompletedOrderPackages;

CompletedCubicMeasure:

load OrderNo, (sum(width) * sum(length) * sum(height))/1728 as CubicSpace

resident Temp group by OrderNo;

drop Table Temp;


talk is cheap, supply exceeds demand
Not applicable

Re: Help: How to multiply??

Thank you so much