Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
amber2000
Creator
Creator

Count Distinct or Count Aggr doesn't return correct values

Hi all,

I'm having difficulties to use a Count distinct() or Count Aggr()

My table haas duplicate values on column SD_Dest_Pallet.

I want to count the Distinct SD_Dest_Pallet's per Date/Aisle_Facturation/Shop_Ens/

Even the simple sum of SD_Shipped_Colli isn't correct, I'll always get 5 colli to much

In my example (that's attached) I'm using only 1 Aisle_Facturation and 1 Shop_Ens tot test the expressions.

I've a chart with a distinct(Count) and another chart with a Aggr (count)

These are the correct values that should be presented in Qlikview:  

SD_Close_DateAisle_FacturationShop_Ens#Colli#PalletColli / Pal Uit
20160331PBL_OVERIGEPricelist_Hyper401580,20
20160401PBL_OVERIGEPricelist_Hyper5911059,10
20160402PBL_OVERIGEPricelist_Hyper341568,20
20160404PBL_OVERIGEPricelist_Hyper396579,20
20160405PBL_OVERIGEPricelist_Hyper10156169,17
20160406PBL_OVERIGEPricelist_Hyper328565,60
20160407PBL_OVERIGEPricelist_Hyper5000,00
TOTAL31223686,72

Does anyone see where the problem is situated in my example please???

Monique

12 Replies
swuehl
MVP
MVP

Why do you expect 10 for April 01? I do get 10 12 pallets:

Aisle_Zone Aisle_Facturation SD_Close_Date Shop_Ens SD_Dest_Pallet
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025174460
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025174477
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025174484
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025174569
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025224097
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025232665
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025232672
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025232689
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025232696
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025232771
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025232788
PBL_OverigePBL_OVERIGE20160401Pricelist_Hyper554001020025232795

edit:

This is the expression I am currently using:

= Sum({$ <[SD_WH] -= {12}, [Aisle_Zone] -= {PBS_Containers, PBS_Displays}> }

aggr(

count({$ <[SD_WH] -= {12}, [Aisle_Zone] -= {PBS_Containers, PBS_Displays}> } DISTINCT [SD_Dest_Pallet])

, [$(=GetCurrentField( Aisle ))] ,[$(=GetCurrentField( Enseigne ))], [$(=GetCurrentField(  Periods ))]

))

amber2000
Creator
Creator
Author

Ah that's because SD_Dest_Pallet 554001020025174460 and 554001020025174569 are already included in

SD_Close_Date 20160331. (a pallet can only be counted once)

swuehl
MVP
MVP

I think you should fix this in your data model.

You can create a flag that indicates the first SD_Close_Date for each pallet, which you then can use to filter in your set expression.

You can create a temporary table with min SD_Close_date and the flag field grouped by an appropriate key (maybe just SD_Dest_pallet), then join this flag back to your facts table.

You can also consider modifying your data model so that you get read of your pallets duplicates, which should simplify your aggregation.

Since we don't know anything about your model or requirement in detail, it's hard to be more specific.