Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
dmac1971
Creator III
Creator III

Sum using If but only Distinct

Having trouble getting my head around the syntax in Qlikview, coming from an excel background.  I have the following which works but I want to exclude duplicates :

='Standard £ : ' & sum({<[TYPE]={'AFTERMARKET'}, [TYPE={'STANDARD'}>} [SO Line Value])

Ive got a unique identifier in field [id] but no matter what I try I end up getting an error or a zero.  I know I need to use {Distinct [id]} but cant figure where it sits in the expression?

Any help much appreciated....

13 Replies
dmac1971
Creator III
Creator III
Author

Sorry should read :

='Standard £ : ' & sum({<[TYPE]={'AFTERMARKET'}, [TYPE2]={'STANDARD'}>} [SO Line Value])

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Are you saying you have duplicate records in your fact table?

preminqlik
Specialist II
Specialist II

hey dermot try this,

sum(aggr(distinct sum({<[TYPE]={'AFTERMARKET'}, [TYPE={'STANDARD'}>} [SO Line Value]),ID)

dmac1971
Creator III
Creator III
Author

Yes, some open orders have duplicate suppliers, so only need to be counted once.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

You may want to look to pull that out into a dimension table using a composite key. Might improve performance.

dmac1971
Creator III
Creator III
Author

No sorry that doesnt work, expression error.

Not applicable

Hi,

Is it possible to post sample excel data?

dmac1971
Creator III
Creator III
Author

No sorry it isnt, id field is a unique identifier though.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Could you use ID as a dimension in the chart?