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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
shamitshah
Partner - Creator
Partner - Creator

If Statement

Hi,

I need some help with an if statement.

I have the following expression which works,

num(Count (DISTINCT if(BST_QtyOnHand >(0),[Item Number])))-NUM(COUNT(DISTINCT{$<FiscalRecordYear={2016},SKH_Source={'SO'},BST_QtyOnHand={'<>0'}>}[Item Number]))

I need an if statement where if the result of the above is <0, then show '0', otherwise the result of the above statement.

Any ideas?

Thanks

Shamit

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

May be this:

Num(If(Count (DISTINCT {<BST_QtyOnHand = {'>0'}>} [Item Number]) - Count(DISTINCT{$<FiscalRecordYear={2016},SKH_Source={'SO'},BST_QtyOnHand={'<>0'}>}[Item Number]) < 0, 0, Count (DISTINCT {<BST_QtyOnHand = {'>0'}>} [Item Number]) - Count(DISTINCT{$<FiscalRecordYear={2016},SKH_Source={'SO'},BST_QtyOnHand={'<>0'}>}[Item Number])))

View solution in original post

4 Replies
pooja_sn
Creator
Creator

=(if(

num(Count (DISTINCT if(BST_QtyOnHand >(0),[Item Number])))-NUM(COUNT(DISTINCT{$<FiscalRecordYear={2016},SKH_Source={'SO'},BST_QtyOnHand={'<>0'}>}[Item Number]))

)<0,0,

num(Count (DISTINCT if(BST_QtyOnHand >(0),[Item Number])))-NUM(COUNT(DISTINCT{$<FiscalRecordYear={2016},SKH_Source={'SO'},BST_QtyOnHand={'<>0'}>}[Item Number]))

)

trdandamudi
Master II
Master II

May be like below:

If(num(Count (DISTINCT if(BST_QtyOnHand >(0),[Item Number])))-NUM(COUNT(DISTINCT{$<FiscalRecordYear={2016},SKH_Source={'SO'},BST_QtyOnHand={'<>0'}>}[Item Number])) <0,

0,

num(Count (DISTINCT if(BST_QtyOnHand >(0),[Item Number])))-NUM(COUNT(DISTINCT{$<FiscalRecordYear={2016},SKH_Source={'SO'},BST_QtyOnHand={'<>0'}>}[Item Number])) )


sunny_talwar
MVP
MVP

May be this:

Num(If(Count (DISTINCT {<BST_QtyOnHand = {'>0'}>} [Item Number]) - Count(DISTINCT{$<FiscalRecordYear={2016},SKH_Source={'SO'},BST_QtyOnHand={'<>0'}>}[Item Number]) < 0, 0, Count (DISTINCT {<BST_QtyOnHand = {'>0'}>} [Item Number]) - Count(DISTINCT{$<FiscalRecordYear={2016},SKH_Source={'SO'},BST_QtyOnHand={'<>0'}>}[Item Number])))

shamitshah
Partner - Creator
Partner - Creator
Author

Thanks  for your reply.

Solution from both Sunny and Thirumala work.

Once again, thanks for your help.

Shamit