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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
BoXiangWang
Contributor III
Contributor III

Pivot table using ValueList as Rows

Hi QS expert,

I am using the pivot table to show the value.

I have two layers of rows:

The first one is the following expression, with the label "Group"

=ValueList('Overall','Indirect HKG','Indirect Region','Cabin Crew','Cockpit Crew','Direct (Others)')

The second one is, with label "YearMonth"

=
Aggr(only({<[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>}
[date_month.autoCalendar.YearMonth]),[date_month.autoCalendar.YearMonth])

 

For the Value I put the following, labeled as "Turnover"

=
Pick(
Match(ValueList('Overall','Indirect HKG','Indirect Region','Cabin Crew','Cockpit Crew','Direct (Others)'),
'Overall','Indirect HKG','Indirect Region','Cabin Crew','Cockpit Crew','Direct (Others)'),
 
sum(aggr(count(distinct {<action_group={'Termination'}, 
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month)),
 
sum(aggr(count(distinct {<direct_indirect_ind={"I"}, Region={'HKG'}, action_group={'Termination'}, 
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month)),
 
sum(aggr(count(distinct {<direct_indirect_ind={"I"}, Region={'Region'}, action_group={'Termination'}, 
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month)),
 
sum(aggr(count(distinct {<employee_class={'CA'}, action_group={'Termination'},
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month)),
 
sum(aggr(count(distinct {<employee_class={'CO'}, action_group={'Termination'},
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month)),
 
sum(aggr(count(distinct {<direct_indirect_ind={'D'}, employee_class-={'CA', 'CO'}, action_group={'Termination'},
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month))
)
 
The table shows:
BoXiangWang_0-1728977164834.png

 

I've checked the expressions but didn't find error. I wonder why only the first row shows the value?

 

Labels (1)
3 Replies
Kushal_Chawda

@BoXiangWang  try with aggr including YearMonth dimension

Pick(
Match(ValueList('Overall','Indirect HKG','Indirect Region','Cabin Crew','Cockpit Crew','Direct (Others)'),
'Overall','Indirect HKG','Indirect Region','Cabin Crew','Cockpit Crew','Direct (Others)'),
 
sum(aggr(count(distinct {<action_group={'Termination'}, 
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month,[date_month.autoCalendar.YearMonth])),
 
sum(aggr(count(distinct {<direct_indirect_ind={"I"}, Region={'HKG'}, action_group={'Termination'}, 
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month,[date_month.autoCalendar.YearMonth])),
 
sum(aggr(count(distinct {<direct_indirect_ind={"I"}, Region={'Region'}, action_group={'Termination'}, 
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month,[date_month.autoCalendar.YearMonth])),
 
sum(aggr(count(distinct {<employee_class={'CA'}, action_group={'Termination'},
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month,[date_month.autoCalendar.YearMonth])),
 
sum(aggr(count(distinct {<employee_class={'CO'}, action_group={'Termination'},
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month,[date_month.autoCalendar.YearMonth])),
 
sum(aggr(count(distinct {<direct_indirect_ind={'D'}, employee_class-={'CA', 'CO'}, action_group={'Termination'},
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]), date_month,[date_month.autoCalendar.YearMonth]))
)
BoXiangWang
Contributor III
Contributor III
Author

Hi Kushal,

Thanks for your reply. I did it but still the table showed 0 apart from the first row.

BoXiangWang
Contributor III
Contributor III
Author

I tried to debug it and tested the following expression, which gave me the outcomes without aggregating and then summing. The result is not what I want. I don't get it why the first row(Overall) could fetch the data but others couldn't.

=
Pick(
Match(
ValueList('Overall','Indirect HKG','Indirect Region','Cabin Crew','Cockpit Crew','Direct (Others)'),
        'Overall','Indirect HKG','Indirect Region','Cabin Crew','Cockpit Crew','Direct (Others)'),
 
count(distinct {<action_group={'Termination'}, 
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]),
 
count(distinct {<direct_indirect_ind={"I"}, Region={'HKG'}, action_group={'Termination'}, 
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]),
 
count(distinct {<direct_indirect_ind={"I"}, Region={'Region'}, action_group={'Termination'}, 
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]),
 
count(distinct {<employee_class={'CA'}, action_group={'Termination'},
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]),
 
count(distinct {<employee_class={'CO'}, action_group={'Termination'},
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk]),
 
count(distinct {<direct_indirect_ind={'D'}, employee_class-={'CA', 'CO'}, action_group={'Termination'},
[date_month]={">=$(=AddMonths(vRollingDate,-11))<=$(=MonthEnd(vRollingDate))"}>} [dim_ppl_employee_sk])
 
)

BoXiangWang_0-1729044103643.png