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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
11deanm
Contributor
Contributor

How To add a column in Data Model Viewer

So I would like to add a column through Data  Model Viewer where its called Commision where I take the 
total_payment - (soldunitprice*quantity) is this something I am able to do? There are two different tables

11deanm_0-1640707542782.png11deanm_1-1640707557877.png

 

11deanm_2-1640707563265.png

 

Labels (2)
1 Solution

Accepted Solutions
Andrei_Cusnir
Specialist
Specialist

Hello,

 

Perhaps you can do something like this:

 

  1. Load the fist dataset to table "Temp"
  2. Load the second dataset and left join to table "Temp"
  3. Create a new table "Orders" from the dataset that is found in table "Temp"
  4. Create the new field, combining the fields from both loaded datasets
  5. Drop the "Temp" table

Here are the load scripts that I have used:

 

//Loading dataset to Temp
Temp:
LOAD
    OrderID,
    CustomerID,
    EmployeeID,
    OrderDate,
    TotalPayment,
    Ostatus

FROM [...]
(...);

 

//Left Join the other dataset to Temp
Left Join Temp:
LOAD
    OrderID,
    ProductID,
    SoldUnitPrice,
    Quantity

FROM [...]
(...);

 

//Create table Orders
Orders:
Load *,
    TotalPayment - SoldUnitPrice * Quantity as Commision
Resident Temp;

 

//Drop Temp table
Drop Table Temp;

 

The loaded dataset looks, in Data model viewer, like:

 

 

I hope that this information was helpful. In case I have misunderstood the use case scenario, please elaborate in details by providing additional information. However, if it has helped you resolve the issue, please mark it as accepted solution to give further visibility to other community members. 
 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂

View solution in original post

1 Reply
Andrei_Cusnir
Specialist
Specialist

Hello,

 

Perhaps you can do something like this:

 

  1. Load the fist dataset to table "Temp"
  2. Load the second dataset and left join to table "Temp"
  3. Create a new table "Orders" from the dataset that is found in table "Temp"
  4. Create the new field, combining the fields from both loaded datasets
  5. Drop the "Temp" table

Here are the load scripts that I have used:

 

//Loading dataset to Temp
Temp:
LOAD
    OrderID,
    CustomerID,
    EmployeeID,
    OrderDate,
    TotalPayment,
    Ostatus

FROM [...]
(...);

 

//Left Join the other dataset to Temp
Left Join Temp:
LOAD
    OrderID,
    ProductID,
    SoldUnitPrice,
    Quantity

FROM [...]
(...);

 

//Create table Orders
Orders:
Load *,
    TotalPayment - SoldUnitPrice * Quantity as Commision
Resident Temp;

 

//Drop Temp table
Drop Table Temp;

 

The loaded dataset looks, in Data model viewer, like:

 

 

I hope that this information was helpful. In case I have misunderstood the use case scenario, please elaborate in details by providing additional information. However, if it has helped you resolve the issue, please mark it as accepted solution to give further visibility to other community members. 
 

Help users find answers! Don't forget to mark a solution that worked for you! 🙂