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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
hobanwashburne
Creator
Creator

Help with SQL

I need to do some calculations on data and cannot have null values.

The original data set contains: Part, Date, & Qty

But not every part was sold on every date. So I split the data into two tables: one containing all possible parts the other containing all possible dates.

Now how can I create a table that contains both?

Pseudo code below:

Data:

Load

   Part & '|' & Date as Part|Date,

   Part,

   Date,

   Qty;

Table A:

Load Distinct

   Part

Resident Data;

Noconcatenate

Table B:

Load Distinct

   Date,

   0 as ZeroQty

Resident Data;

Help needed

Table C:

Load

   Part|Date

   ZeroQty;

Left Join(Table C)

Load

   Part|Date,

   Part,

   Date,

    Qty;

Resident

   Data;

Drop Table Data;

Noconcatenate

Final Result:

Load

   Part|Date,

   Part,

   Date,

   ZeroQty + Qty as TotalQty

Resident

   Table C;

Drop Table C;

Labels (1)
13 Replies
Anonymous
Not applicable

can you give us some more details.

hobanwashburne
Creator
Creator
Author

You are correct. However, "A" is a possible part and "H" is a possible attribute and therefore a valid data point. What I am seeking is all possible combinations.

hobanwashburne
Creator
Creator
Author

If we go back to thinking in terms of dates

   

PartAttributeQty
AE3
AF1
AG1
BG6
BH3

is equal to

 

PartDateQty
A1/1/20163
A2/1/20161
A3/1/20161
B3/1/20166
B4/1/20163

Part A and Attribute H would be the Equivalent of Part A for the month of April. Part A and April exist, there were simply none sold.

sunny_talwar
MVP
MVP

Did you look at my response below? Re: Help with SQL