Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
ThomasSilva
Contributor II
Contributor II

how to sum value with concat and aggr on qliksense

Hi everybody, does anybody know how to sum this sentence ?

I have a columm with this expression :
=aggr(concat ([qtd_item]&' x '&[cód_proced_mat]&' - '&[description_item]&chr(10))
,[medical_name],[date_item],[cód_people])

and she returns this value:
"1,0000 x 30303030 - description"
"1,0000 x 40404040 - description"
"1,0000 x 40404040 - description"
"1,0000 x 40404040 - description"

but i need the sum of "qtd_item", same of this:
"1,0000 x 30303030 - description"
"3,0000 x 40404040 - description"

any1 know how i can sum this ? 
Thanks in advance.

Labels (1)
1 Solution

Accepted Solutions
ThomasSilva
Contributor II
Contributor II
Author

Guys, i can sum qtd_iten with this sentence, it's returns i needed:

concat(aggr(sum([qtd_item])&' x '&[cód_proced_mat]&' - '&[description_item]&chr(10),[cód_proced_mat],[medical_name],[date_item],[cód_people]))

Thanks all for reply.

Thomas.

View solution in original post

5 Replies
eddie_wagt
Partner - Creator III
Partner - Creator III

Do you use this expression as a dimension or as expression? The syntax of the concat is not right. If you use this as an expression you could simply use this:

sum([qtd_item])&' x '&[cód_proced_mat]&' - '&[description_item]

If you use qtd_item + cód_proced_mat + description_item as a calculated dimension then use this

aggr(sum([qtd_item])&' x '&[cód_proced_mat]&' - '&[description_item],[medical_name],[date_item],[cód_people])

But it is better to make this field in de load editor. Depends on how you tables look like, but could be something like this

Tab1:
LOAD * Inline [key	qtd_item	cód_proced_mat	description_item
1	1,0000	30303030	description
2	1,0000	40404040	description
3	1,0000	40404040	description
4	1,0000	40404040	description
] (delimiter is '	')
;

left join (Tab1) 
LOAD * INLINE [key, medical_name
1, name1
2, name2
3, name2
3, name3
];

left join (Tab1) 
LOAD * INLINE [key, date_item
1, 01-01-2022
2, 02-02-2022
3, 02-02-2022
4, 03-02-2022
];

left join (Tab1) 
LOAD * INLINE [key, cód_people
1, person1
2, person1
3, person1
4, person1
];


left join (Tab1) 
LOAD medical_name
,	 date_item
,	 cód_people
,   sum(qtd_item)&' x '&only([cód_proced_mat])&' - '&only([description_item]) as New_field
Resident Tab1
Group By medical_name
,		 date_item
,		 cód_people
;
ThomasSilva
Contributor II
Contributor II
Author

Thanks for reply eddie,

But if i remove function Concat(), the codes are not concatenate, returning only first code on columm.
i go test on load script, and post here if i get sucess.

thank you for now.



SunilChauhan
Champion II
Champion II

Try this

 

=sum(aggr(sum([qtd_item]),[medical_name],[date_item],[cód_people]))&' x '&[cód_proced_mat]&' - '&[description_item]&chr(10)

Sunil Chauhan
ThomasSilva
Contributor II
Contributor II
Author

hi IamBack,

this function not work, he sum all itens, but i need the sum for each [cód_proced_mat]

Thanks

ThomasSilva
Contributor II
Contributor II
Author

Guys, i can sum qtd_iten with this sentence, it's returns i needed:

concat(aggr(sum([qtd_item])&' x '&[cód_proced_mat]&' - '&[description_item]&chr(10),[cód_proced_mat],[medical_name],[date_item],[cód_people]))

Thanks all for reply.

Thomas.