Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Grouping by parameters

How do i group by Month and Year same time. See attached Only Year is associated with the Total When I click on Month the Total disappears.

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

Hi,

Try this in your script..

T:
LOAD No,
Text,
Year,
Months,
Data
FROM
[0215_184014.xls]
(
biff, embedded labels, table is Sheet1$);

STORE T into T.qvd(qvd);

NoConcatenate
Final:
Load *,
1
as SORT
Resident T
Where WildMatch(No, '*14*', '*20*', '*21*','*22*', '*36*','*24*');

Concatenate(Final)
Load Dual ('Total equipment:',1) as Text,
Year,
Sum(Data) as Data,
No,
Months,
2
as SORT
RESIDENT T
where WildMatch(No, '*14*', '*20*', '*21*','*22*', '*36*','*24*')
Group By Year,
No,
Months;

Concatenate(Final)
Load *,
3
as SORT
Resident T
Where WildMatch(No, '*26*', '*27*', '*28*');

Concatenate(Final)
Load Dual ('Total Work:',2) as Text,
Sum(Data) as Data,
Year,
No,
Months,
4
as SORT
RESIDENT T
where wildmatch(No, '*26*', '*27*', '*28*')
Group By Year,
No,
Months;

Concatenate(Final)
Load *,
5
as SORT
Resident T
Where WildMatch(No, '*26*', '*27*', '*28*', '*14*', '*20*', '*21*','*22*', '*36*','*24*');

Concatenate(Final)
Load Dual ('TOTAL:',3) as Text,
Sum(Data) as Data,
Year,
No,
Months,
6
as SORT
RESIDENT T
Where WildMatch(No, '*26*', '*27*', '*28*', '*14*', '*20*', '*21*','*22*', '*36*','*24*')
Group By Year,
No,
Months
Drop Table T;

View solution in original post

9 Replies
daveamz
Partner - Creator III
Partner - Creator III

Hi,

You can use:

Sum({<Text = {'*'}-{'*total*'}>}Data)+

Sum({<Text = {'*total*'}, Months=>}Data)

But when you will select one month, the values for cost, Depreciate, equip....will be only for that month an the totals will be for the whole year.

Regards,

David

mightyqlikers
Creator III
Creator III

hi

there is issue in your data. thats y it is not displaying totals when u select month.

give sample data in excel.

Regards

$@

Not applicable
Author

No there is no issue with the data. Total was brought in let me say calculatedly from the backend

tresesco
MVP
MVP

While summing the data in the script group it by two fields like:

Load

    'Total' as Text,

    Year,

    Month,

    Sum(Data) as Data

Resident T Group By Year, Month;

Anonymous
Not applicable
Author

Total is getting disappeared becoz it is not associated with your Month field....

Check the attachment....

Also, your text of total is coming in Right which means its in number format not into string

Not applicable
Author

Hi,

Can you please try by concatenating Year and Month like '201601', 201602, .. and you do group by based on this concatenated column.

Thanks,

Sreeman

Not applicable
Author

Tried it didnt work

settu_periasamy
Master III
Master III

Hi,

Try this in your script..

T:
LOAD No,
Text,
Year,
Months,
Data
FROM
[0215_184014.xls]
(
biff, embedded labels, table is Sheet1$);

STORE T into T.qvd(qvd);

NoConcatenate
Final:
Load *,
1
as SORT
Resident T
Where WildMatch(No, '*14*', '*20*', '*21*','*22*', '*36*','*24*');

Concatenate(Final)
Load Dual ('Total equipment:',1) as Text,
Year,
Sum(Data) as Data,
No,
Months,
2
as SORT
RESIDENT T
where WildMatch(No, '*14*', '*20*', '*21*','*22*', '*36*','*24*')
Group By Year,
No,
Months;

Concatenate(Final)
Load *,
3
as SORT
Resident T
Where WildMatch(No, '*26*', '*27*', '*28*');

Concatenate(Final)
Load Dual ('Total Work:',2) as Text,
Sum(Data) as Data,
Year,
No,
Months,
4
as SORT
RESIDENT T
where wildmatch(No, '*26*', '*27*', '*28*')
Group By Year,
No,
Months;

Concatenate(Final)
Load *,
5
as SORT
Resident T
Where WildMatch(No, '*26*', '*27*', '*28*', '*14*', '*20*', '*21*','*22*', '*36*','*24*');

Concatenate(Final)
Load Dual ('TOTAL:',3) as Text,
Sum(Data) as Data,
Year,
No,
Months,
6
as SORT
RESIDENT T
Where WildMatch(No, '*26*', '*27*', '*28*', '*14*', '*20*', '*21*','*22*', '*36*','*24*')
Group By Year,
No,
Months
Drop Table T;

Not applicable
Author

It would be helpful to provide me the dummy data and with the expected output.