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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
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-1701584211409.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.

Labels (3)
1 Reply
rubenmarin

Hi, if 'CP' and 'ORG' are the only values on that field you can do:

Table:
LOAD 
  CP_Team_Flag,
  Sales_District,
  If(Peek(Sales_District)=Sales_District
    ,If(Peek(TerrCount)>TerrCount
      ,Peek(TerrCount)
      ,TerrCount)
    ,TerrCount) as TerrCount
Resident tmpTable
Order By Sales_District, CP_Team_Flag desc;

DROP table tmpTable;