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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
SariPari
Creator
Creator

if statement

I have the below table - 

City ID Capacity HC MAXCAPACITY COMBINEDHC CapacityRank Output
Bangalore BLR09 408 318 408 551 1 318
Bangalore BLR86 265 233     2 233
Boston BOS04 402 234 402 300 1 300
Boston BOS50 114 66     2 0

 

Need the Output as above -

If (MAXCAPACITY > COMBINEDHC, COMBINEDHC ,

 If (MAXCAPACITY < COMBINEDHC, HC))

Also - if MAXCAPACITY > COMBINEDHC only CapacityRank with ranl 1 should have the value and other one should be 0.

 

Thank you so much.

@swuel @Jagmeet_singh @Sunny @randres_talend @Anil_Babu_Samineni 

 

1 Solution

Accepted Solutions
Anil_Babu_Samineni

@SariPari Perhaps this?

If (MAXCAPACITY > COMBINEDHC and CapacityRank=1, COMBINEDHC,
If(Sum(TOTAL <City> HC)>Sum(TOTAL <City> MAXCAPACITY),Sum(HC), 0))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

10 Replies
LRuCelver
Partner - Creator III
Partner - Creator III

If(MAXCAPACITY > COMBINEDHC,
If(CapacityRank = 1, COMBINEDHC, 0)
  If(MAXCAPACITY < COMBINEDHC, HC, /*MAXCAPACITY = COMBINEDHC goes here*/)
)

 

SariPari
Creator
Creator
Author

@LRuCelver - Thank you, but that did not work.

 

SariPari_0-1707487543795.png

 

Anil_Babu_Samineni

@SariPari For City='Bangalore' and ID='BLR86', why there is value in the output?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
mato32188
Specialist
Specialist

Hi @SariPari ,

try to use expression: 

If (MAXCAPACITY > COMBINEDHC, only( {<CapacityRank  = {1}>} COMBINEDHC),

If (MAXCAPACITY < COMBINEDHC, sum(HC),0))

Best regards,

Martin

 

ECG line chart is the most important visualization in your life.
Chanty4u
MVP
MVP

Try this

if(MAXCAPACITY > COMBINEDHC,

        if(CapacityRank = 1, COMBINEDHC, 0),

        HC) as Output

SariPari
Creator
Creator
Author

In one city, if there are 2 records and Combined HC is < MaxCapacity, then use Combined HC for that city and if combined HC is > Max capacity by City keep original caapcity.

SariPari
Creator
Creator
Author

SariPari_0-1707676187827.png

 

This 66 should be 0.

SariPari
Creator
Creator
Author

SariPari_0-1707678418094.png

 

output should have 233 for BLR86

Anil_Babu_Samineni

@SariPari Perhaps this?

If (MAXCAPACITY > COMBINEDHC and CapacityRank=1, COMBINEDHC,
If(Sum(TOTAL <City> HC)>Sum(TOTAL <City> MAXCAPACITY),Sum(HC), 0))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful