Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
srinivasa1
Creator II
Creator II

Calculate sum when I select related group,

Can someone guide me how I can write best code dynamically to achieve sum when I select different product form list box  I have attached sample example. Please guide or Please also let me know in case i need to create some sort of mapping table again

Thanks in advance.

3 Replies
sunny_talwar

How is this association made? Is there a logic behind combining PR1 and PR3 and PR2 and PR5?

sunny_talwar

May be like this....

Script:

[MapPCode]:

Mapping

LOAD * INLINE [

From , To

P,PR1

];

Product:

LOAD Date,

    ApplyMap('MapPCode',[Product  Code]) as [Product  Code],

    If(Match(ApplyMap('MapPCode',[Product  Code]), 'PR1', 'PR3'), 'Group1',

    If(Match(ApplyMap('MapPCode',[Product  Code]), 'PR5', 'PR7'), 'Group2', [Product  Code])) as Group,

    Value

FROM

[ProductMap.xlsx]

(ooxml, embedded labels, table is PRODUCT);

Left join(Product)

LOAD * INLINE [

Product  Code, Product  Desc

PR1, PRODUCT 1,

PR2, PRODUCT 2,

PR3, PRODUCT 3,

PR4, PRODUCT 4,

PR5, PRODUCT 5,

PR6, PRODUCT 6,

PR7, PRODUCT 7,

PR8, PRODUCT 8,

PR9, PRODUCT 9,

PR10, PRODUCT 10

];

Expression:

=Sum({<[Product  Code]=, Group = p(Group)>} Value)

johnw
Champion III
Champion III

A different approach to building product groups. I usually leave the groups as a separate table. Not sure why I do. I just do.

[Product Groups]:
LOAD
[Product Group]
,
subfield([Products],',') as [Product Code]
INLINE [
Product Group:Products
PR1:PR1,PR3
PR2:PR2,PR5
]
(delimiter is ':');