Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
janus2021
Contributor III
Contributor III

divide a value into two other variables.

Hi.

Hi.

how do i divide a value in one variable and assign to 2 other given variables 50% each or if possible divide v1 randomly and assign it to v2 and v3.

Example 1: v1 is the variable to divide into v2 and v3.
v1: 30
v2: 25
v3: 20

result:
v2: 40
v3: 35

Example 2: v1 is the variable to divide into v2 and v3.
v1: 21
v2: 10
v3: 20

result:
v2: 20
v3: 31

Example 3 Randomly: v1 is the variable to divide into v2 and v3.
v1: 21
v2: 10
v3: 20

result:
v2: 25
v3: 36

Labels (4)
1 Solution

Accepted Solutions
Andrei_Cusnir
Specialist
Specialist

Hello,

 

Here are some options that you can use in Data load editor:

 

//Use case scenario 1:
Let v1 = 30;
Let v2 = 25;
Let v3 = 20;

 

//Divide v1 and assign to v2 and v3
Let v2 = $(v1)/2 + $(v2);
Let v3 = $(v1)/2 + $(v3);

 

//Print data:
Trace V1 value: $(v1);
Trace V2 value: $(v2);
Trace V3 value: $(v3);

 

Outcome:

 

//Use case scenario 2:
Let v1 = 21;
Let v2 = 10;
Let v3 = 20;

 

//Divide v1 and assign to v2 and v3
Let v2 = Floor($(v1)/2) + $(v2);
Let v3 = $(v1) - Floor($(v1)/2) + $(v3);

 

//Print data:
Trace V1 value: $(v1);
Trace V2 value: $(v2);
Trace V3 value: $(v3);

 

Outcome:

 

//Use case scenario 3:
Let v1 = 21;
Let v2 = 10;
Let v3 = 20;

 

//Divide v1 and assign to v2 and v3
Let randomNumber = ROUND((rand()*1),0.1);
Trace Random number: $(randomNumber);

Let v2 = Floor($(v1)*randomNumber) + $(v2);
Let v3 = $(v1) - Floor($(v1)*randomNumber) + $(v3);

 

//Print data:
Trace V1 value: $(v1);
Trace V2 value: $(v2);
Trace V3 value: $(v3);

 

Outcome:

 

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

2 Replies
Andrei_Cusnir
Specialist
Specialist

Hello,

 

Here are some options that you can use in Data load editor:

 

//Use case scenario 1:
Let v1 = 30;
Let v2 = 25;
Let v3 = 20;

 

//Divide v1 and assign to v2 and v3
Let v2 = $(v1)/2 + $(v2);
Let v3 = $(v1)/2 + $(v3);

 

//Print data:
Trace V1 value: $(v1);
Trace V2 value: $(v2);
Trace V3 value: $(v3);

 

Outcome:

 

//Use case scenario 2:
Let v1 = 21;
Let v2 = 10;
Let v3 = 20;

 

//Divide v1 and assign to v2 and v3
Let v2 = Floor($(v1)/2) + $(v2);
Let v3 = $(v1) - Floor($(v1)/2) + $(v3);

 

//Print data:
Trace V1 value: $(v1);
Trace V2 value: $(v2);
Trace V3 value: $(v3);

 

Outcome:

 

//Use case scenario 3:
Let v1 = 21;
Let v2 = 10;
Let v3 = 20;

 

//Divide v1 and assign to v2 and v3
Let randomNumber = ROUND((rand()*1),0.1);
Trace Random number: $(randomNumber);

Let v2 = Floor($(v1)*randomNumber) + $(v2);
Let v3 = $(v1) - Floor($(v1)*randomNumber) + $(v3);

 

//Print data:
Trace V1 value: $(v1);
Trace V2 value: $(v2);
Trace V3 value: $(v3);

 

Outcome:

 

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! 🙂
janus2021
Contributor III
Contributor III
Author

Thanks, worked perfectly.