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

Announcements
Data Works for AI is here - Join the discussion and enter to win a pair of Qlik kicks: Join the Conversation!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Avg in labor days and weekend days

Hello all,

I have a variable v_Date7days.

I have a pivot table with the following dimension and want to display only the 31 days less than my variable v_Date7days --> this is not my problem!

I also have an expression:

sum(Qty)



The next expression is where I have a problem.

As you know within the dimension range we have labor and weekend days. I need to have an expression that calculate an average only for labor days and another expression for the weekend days.

I have a field that give me that information (Val_Labor_Days=1 and Val_Weekend_Days=1)

Does anyone have any idea how to solve this?

Thanks in advance.

João



=if(Date>v_Date7days-31 and Date<=v_Date7days, date(Date))

Labels (1)
5 Replies
Miguel_Angel_Baeyens
Support
Support

Hello Joao,

You already have networkdays() function that returns the number of working days between two dates, something like

networkdays('01/01/2010', '31/01/2010')
You may use this function instead.

Not applicable
Author

Hi,

If you have a Field named Val_Labor_days containg 1, if it is a labor day an Null otherwise.

And you want to do an avg on the labor days.

Can't you simply do a "avg(Qty * Val_Labor_days)"

Or using set analysis "avg({$<Val_Labor_days={"1"}>} Qty)"

BR

Hans

Not applicable
Author

But in the date range I also could have holidays (Carnival -2010/02/16) and is considered in the group of weekend/holidays.

I need to:

sum(Qty) for the labor days / count(distinct Date) --> but only for the ones indicated in the dimension

Not applicable
Author

Hello Hans,

if I use the set analysis the result it shows is always "1".

It doesn't work

Best rgs

João

Not applicable
Author

Hello again,

I'm trying the following expression:

count({$<Date {">$(date(v_Date7days)-31)"}, Date {"<=$(date(v_Date7dias))"}, Val_Labor_Day= {1}>} total distinct Date) --> count Labor Days



and it gaves me 26 for all the days (the total number of days in 2010).

I need to have the avg of labor days (should be sum(total column(2)/number Labor days (21).

The same for weekend days (10).

I will have only 2 distinct avg. One for labor (181 695) and other for weekends (69 242)

DateTotal QtyQty Labor DaysQty Weekend dayscount Labor Days
09-01-201086.176086.17626
10-01-201048.960048.96026
11-01-2010186.241186.241026
12-01-2010170.967170.967026
13-01-2010169.148169.148026
14-01-2010182.650182.650026
15-01-2010181.725181.725026
16-01-201078.588078.58826
17-01-201048.740048.74026
18-01-2010178.204178.204026
19-01-2010185.717185.717026
20-01-2010185.940185.940026
21-01-2010183.327183.327026
22-01-2010189.221189.221026
23-01-201089.206089.20626
24-01-201056.581056.58126
25-01-2010183.948183.948026
26-01-2010182.581182.581026
27-01-2010183.790183.790026
28-01-2010182.536182.536026
29-01-2010185.079185.079026
30-01-201088.463088.46326
31-01-201055.602055.60226
01-02-2010181.412181.412026
02-02-2010194.009194.009026
03-02-2010182.418182.418026
04-02-2010175.350175.350026
05-02-2010178.354178.354026
06-02-201083.292083.29226
07-02-201056.807056.80726
08-02-2010172.982172.982026


I really need your help.

Bst rgs~

João