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: 
coddra_6
Contributor III
Contributor III

Max by State

Hey,

I have the next case:

I have the sales of many products by state y I wanna know which product is the best selling by each state. I have the next table:

State         Producto   Sales

=====         ========   ======

New York      Cookie     1500

New York      Soda        890

California    Chocolate  2100

California    Candy      2015

California    Cookie     2085

And I wanna got the next table:

State         Producto   Sales

=====         ========   ======

New York      Cookie     1500

California    Chocolate  2100

Hope your help!!

Thanks!!

5 Replies
swuehl
MVP
MVP

Create a chart with dimension State, then two expressions

=FirstSortedValue(Producto, -Sales)

=max(Sales)

qlikpahadi07
Specialist
Specialist

May be this help you

coddra_6
Contributor III
Contributor III
Author

Yeah!! This helps!!

And if I wanna make it in the Script Editor??

maxgro
MVP
MVP

you have to change column name, I started from your post http://community.qlik.com/thread/102682

Tab:

LOAD * INLINE [

    Departamento,   Producto,     Ventas

    Ica,            Galleta,        1500

    Ica,            Gaseosa,         890

    Lima,           Chocolate,      2100

    Lima,           Caramelo,       2015

    Lima,           Galleta,        2085

];

Tab2:

NoConcatenate load Departamento, Producto, Ventas

where Flag=1;

NoConcatenate load

Departamento, Producto, Ventas, if(Peek(Departamento)<>Departamento or IsNull(Departamento), 1, 0) as Flag

resident Tab

order by Departamento, Ventas desc;

drop table Tab;

qlikpahadi07
Specialist
Specialist

here is from Script might be helpful

Merry Christmas !!!!