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: 
dineshm030
Creator III
Creator III

Get the value from one row to another row based on the condition in the script

Hi,

Based on the month condition, I need to populate the value from one row to another. If the CP data has lower terr counts, we must incorporate the ORG terr counts (CP < ORG) in the script.

Kindly help me out.

dineshm030_0-1701582884934.png

Expected Output:

CP_Team_Flag Sales_District TerrCount
CP IN1001 1
ORG IN1001 1
CP IN1028 2
ORG IN1028 2
CP IN5002 4
ORG IN5002 1

 

Thanks in advance.

@sunny_talwar @MayilVahanan 

Labels (2)
4 Replies
sidhiq91
Specialist II
Specialist II

@dineshm030  Please use the below expression in your Table:

=if(Sales_District=below(Sales_District) and TerrCount<Below(TerrCount), Below(TerrCount), TerrCount)

sidhiq91_0-1701585169225.png

If this resolves your issue, please like and accept it as a solution.

dineshm030
Creator III
Creator III
Author

Hi Sidhiq,

Thanks for your response.

This logic is working at the expression level, but I need it like this at the script level.

dineshm030
Creator III
Creator III
Author

Hi @sidhiq91 ,

The logic is working fine without a Business Unit at the expression level.

dineshm030_0-1701663230125.png

Once I add the business unit, the value has been changed at the expression level.

dineshm030_1-1701663260547.png

Sorting Order :

dineshm030_3-1701663462420.png

Kindly help me out.

Thanks in advance.

 

MayilVahanan

Hi

For Script level,

if all the fields are coming from same table. you can create one mapping table for "ORG" and bring one more field in the table.

In front end, you can compare the value and use it accordingly.

 

Ex:

MAPORG:
Mapping
LOAD Sales_District, TerrCount INLINE [
CP_Team_Flag, Sales_District, TerrCount
ORG, IN1001, 1
ORG, IN1028, 2
ORG, IN5002, 1
]where CP_Team_Flag = 'ORG';


LOAD *, ApplyMap('MAPORG', Sales_District, 0) as ORGTerrCount INLINE [
CP_Team_Flag, Sales_District, TerrCount
CP, IN1001, 1
ORG, IN1001, 1
CP, IN1028, 2
ORG, IN1028, 2
CP, IN5002, 4
ORG, IN5002, 1
];

 

Exp: If(ORGTerrCount > TerrCount, ORGTerrCount, TerrCount)

 

However, its depends on the cardinality and data.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.