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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

using min or minstring function in table/chart

I have these fields: Product_Name, SKU, Volume. Each product might have several SKUs. I want to pick only one SKU out of several in chart/table. In other words, I want to recreate SQL statement "select Product_Name, min(SKU), sum(volume) from table group by Product_Name"

When I go to "Dimensions" and add SKU, click on Edit and put formula =min(SKU) or minstring(SKU), I have error in the field "// error in calculated dimension".

Please advise.

1 Solution

Accepted Solutions
wizardo
Creator III
Creator III

hi benkes1,

min() is an aggragation function and as such it needs a dimesnion(groupg by) to iterate over.

if what you want is a new dimesnion where you have a list of values that are the min:SKU for each product then you will need to use the aggr() function in the dimensionTab. somthing like this:

aggr(min(SKU) , Product_Name)

in the expressionTab add this expression:

sum(volume)

you will get a table with 2 columns

one will list all the lowest SKU of each product and the other will list the sum of volume for each.

but this way you will not have the product in the table,

and if you add the product as dimension then it might not be neccesery to use the aggr() function at all.

something like this:

create a new chart

in the dimensionTab add "Product_Name" as dimension

in the expressionTab add these 2 expressions:

min(SKY)

sum(volume)

this is the same as your SQL quary

hope i helped

Mansyno

View solution in original post

1 Reply
wizardo
Creator III
Creator III

hi benkes1,

min() is an aggragation function and as such it needs a dimesnion(groupg by) to iterate over.

if what you want is a new dimesnion where you have a list of values that are the min:SKU for each product then you will need to use the aggr() function in the dimensionTab. somthing like this:

aggr(min(SKU) , Product_Name)

in the expressionTab add this expression:

sum(volume)

you will get a table with 2 columns

one will list all the lowest SKU of each product and the other will list the sum of volume for each.

but this way you will not have the product in the table,

and if you add the product as dimension then it might not be neccesery to use the aggr() function at all.

something like this:

create a new chart

in the dimensionTab add "Product_Name" as dimension

in the expressionTab add these 2 expressions:

min(SKY)

sum(volume)

this is the same as your SQL quary

hope i helped

Mansyno