Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Asuod_
Contributor III
Contributor III

Adding Variables from Input form into Table

Hello,

I'm new to using partial load in Qlik Sense, and I'm trying to achieve the following with my script:

Every time a partial load is triggered, I want to take the values stored in the variables $(writeback_key), $(writeback_attribute), $(writeback_value), $(timestamp_value), and $(vUser) and append them to the current table.

For Example:

I have the follow initial dataset.

ID Category  Value writeback_value timestamp_value User
1 Clothing 100      
1 Electronics 30      
2 Furniture 50      
3 Electronics 50      

 

Using an input form, which asks for the ID, Variable, writeback_value, Timestamp, and User, the end user can provide new values. For example, if the end user submits:

  • ID = 1
  • Category = Electronics
  • writeback_value = 50
  • timestamp_value = 5/21/2024
  • User = User4

When they hit the partial load button, I want the new data to be appended to the existing table, and it just keeps overwriting the value if they wanted to change the writeback_value for ID = 1 and Category = Electronics again. 

the updated table should look like this:

ID Category  Value writeback_value timestamp_value vUser
1 Clothing        
1 Electronics 30 50 5/21/2024 1555
2 Furniture        
3 Electronics        

 

Any help is appreciated thank you



IF IsPartialReload() THEN

  Personnelwb:

  Add LOAD

  *

   Inline [

  "ID","variable","writeback_value","timestamp_value", "User_value"

  $(writeback_key), $(writeback_attribute), $(writeback_value), $(timestamp_value), $(vUser)

  ];

 

//   drop table max_timestamp;

 

//   max_timestamp:

//   Add Load

//           dod_edi_pn_id,

//     variable,

//     Max(timestamp_value) as timestamp_value_max

//   resident Personnelwb Group By dod_edi_pn_id, variable;

 

//   left Join (Personnelwb)

//     Add Load  

//           dod_edi_pn_id,

//     variable,

//     timestamp_value_max

//   resident max_timestamp;

 

//   drop table max_timestamp;

 

//   Rename Table Personnelwb to Personnelwb_temp;

 

//   Personnelwb:

//   add load *,

//   if (timestamp_value < timestamp_value_max, 'Overwritten', 'Current') as timestamp_status

//   Resident Personnelwb_temp;

 

//   Drop Table Personnelwb_temp;

ELSE

  Personnelwb:

  LOAD

  *

   Inline [

  "ID","variable","writeback_value","timestamp_value", "User_value"

  " "," "," "," ", " "

  ];

END IF;

 

 

Labels (1)
2 Replies
robert1997b
Contributor
Contributor

You have an initial dataset with columns: ID, Category, Value, writeback_value, timestamp_value, and User. Users can provide new values for ID, Category, writeback_value, timestamp_value, and User through an input form. When users hit the partial load button, you want the new data to be appended to the existing table. If the same ID and Category combination exists, the writeback_value should overwrite the existing value. The updated table should look like the one you’ve provided, with the new values incorporated.

IF IsPartialReload() THEN
Personnelwb:
Add LOAD *
Inline [
"ID","Category","Value","writeback_value","timestamp_value","vUser"
$(writeback_key), $(writeback_attribute), null(), $(writeback_value), $(timestamp_value), $(vUser)
];
ELSE
Personnelwb:
LOAD *
Inline [
"ID","Category","Value","writeback_value","timestamp_value","vUser"
" "," "," "," ", " "
];
END IF;

Asuod_
Contributor III
Contributor III
Author

Hello, 

thank you for the reply. I have tried this script you referenced above and when I would make another change to the same ID and Category then it causes a duplicate row with the new writeback_data. So the first time it replaced but then the second it makes a duplicate row.

Andrew