Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Edyta
Contributor III
Contributor III

Cannot get daily production in Qlik Sense

Hi guys,

I am trying to obtain simple pivot table in Qlik Sense. Everything is fine but I cannot get daily production in items.

Below is piece of raw data:

WEEKDAYMONTHYEARNUMBER OF ITEMSITEMS REJECTED
12120192 50412
12120193 75854
13120194 52232
13120195 21945
13120194 4205
141201931 29262
141201934 18454
141201930 57347

 

 

Below is the result is the pivot table - the last column AvgDailyItemsProduced is wrongly calculated by Qlik.

I also present how I get CountProductionDays and ItemsProduced:

CountProductionDays: count(distinct [DAY])

ItemsProduced: sum(NUMBER OF ITEMS)-sum(ITEMS REJECTED)

I also tried to get AvgDailyItemsProduced which is the sum of ItemsProduced/CountProductionDays:

sum(NUMBER OF ITEMS)-sum(ITEMS REJECTED)/count(distinct [DAY]) and I obtain wrong value

 CountProductionDaysItemsProducedAvgDailyItemsProduced
2019   
1225 156 325=ItemsProduced/CountProductionDays
2236 235 248=ItemsProduced/CountProductionDays
3245 902 647=ItemsProduced/CountProductionDays
4265 455 658=ItemsProduced/CountProductionDays

 

Could you help me with the issue?

Labels (2)
1 Solution

Accepted Solutions
JordyWegman
Partner - Master
Partner - Master

Then try this formula again:

Sum(Aggr(count(distinct [DAY],Month))) 

Jordy

Climber 

Work smarter, not harder

View solution in original post

15 Replies
JordyWegman
Partner - Master
Partner - Master

Hi Edyta,

If this is the way you calculated it, it's basic maths that goes wrong here. The * will always be calculated first before the - .

Try the following calculation with the extra brackets around the sums:

(sum(NUMBER OF ITEMS)-sum(ITEMS REJECTED)) /count(distinct [DAY]) 

 Jordy

Climber

Work smarter, not harder
Edyta
Contributor III
Contributor III
Author

I got it properly per month, but it counts wrongly production for the year of 2019.

Any ideas?

Edyta
Contributor III
Contributor III
Author

The value of daily production for the year should be at similar level as the monthly production daily.

I got yearly prodution daily at level 859 734

for January I got 240 895

for February 230 452

JordyWegman
Partner - Master
Partner - Master

But for a year you can't use the distinct amount of days. Try this formula. I don't know what your 'Month' name really is, but fill in your Month column name. 

(sum(NUMBER OF ITEMS)-sum(ITEMS REJECTED)) / Sum(Aggr(count(distinct [DAY],Month))) 

Jordy

Climber

Work smarter, not harder
Edyta
Contributor III
Contributor III
Author

The option you have provided does not work.

The column DAY of my data contains applicable number of day of year, so in fact each day has different number, thus the formula should count distinct number of production days for particular month and year.

JordyWegman
Partner - Master
Partner - Master

What is the number that you would expect? Can you give also the numerator and denominator? For example, one table with the values per month and one for a year, maybe in Excel?

Jordy

Climber

Work smarter, not harder
Edyta
Contributor III
Contributor III
Author

Some ideas came to my mind. CountProductionDays are properly counted per month but wrongly calculated per year.

I need to get the sum of CountProductionDays of each month for the year of 2019.

 

What I am getting now
 CountProductionDaysItemsProducedAvgDailyItemsProduced
20193121 856 054705 034,00
1265 256 545202 174,81
2226 545 669297 530,41
3255 487 855219 514,20
4224 565 985207 544,77
    
The solution I need to get
 CountProductionDaysItemsProducedAvgDailyItemsProduced
20199521 856 054230 063,73
1265 256 545202 174,81
2226 545 669297 530,41
3255 487 855219 514,20
4224 565 985207 544,77

 

With this formula count( distinct[DAY]) I got wrong number of production days for the year.

Any ideas how to solve it?

JordyWegman
Partner - Master
Partner - Master

That 31 is strange, because it looks like you have duplicates and its only counting the distincts and that is 31 because the max in a month is 31 days..

If you want the sum, you can go the calculation, check the Totals function and set this to Sum. This will sum all the monthly values.

Jordy
Climber

Work smarter, not harder
Edyta
Contributor III
Contributor III
Author

sum is not the solution.

I use 'count (distinct DAY)' because I need to obtain all distinct days, each day has its seperate number, thus I have no idea why CountProductionDays shows incorrect value for the year of 2019.

 

Regards

Edyta