Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to sum-up only the maximum values based on particular Field?

Hi QV Team,

Can you help me to total only the maximum values?

Please see the attached excel sheet for more details.

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

The maximum values are subtotals. You should not load these, rather let QV calculate the totals. Or load only the subtotals and not the detail if that is what you require. What you should not do is load both as every expression in your data model will be more complex and (if your data set is large) may perform very badly.

This script will exclude the subtotals:

Pre:

LOAD [Sales Order],

    [Customer ID],

    [Serial Number],

    [Net Value],

    RowNo() As RowID

FrOM

(ooxml, embedded labels, table is Sheet1, filters(

Replace(1, top, StrCnd(null)),

Replace(2, top, StrCnd(null)),

Replace(3, top, StrCnd(null))

));

Final:

NoConcatenate

LOAD [Sales Order],

    [Customer ID],

    [Serial Number],

    [Net Value],

    RowID

Resident Pre

Where [Sales Order] = Previous([Sales Order])

  AND [Customer ID] = Previous([Customer ID])

  AND ([Serial Number]) = Previous ([Serial Number])

Order By RowID DESC;

DROP Table Pre;

Now you can use display the data in a straight table with  [Sales Order],  [Customer ID], [Serial Number] as dimensions and Sum([Net Value]) in an expression.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

5 Replies
mukesh24
Partner - Creator III
Partner - Creator III

Hi Mrunali,

U can achieve these in backend script as :-

Load max(Net_Value) as MaxNetValue,

          SalesOrder,

          etc

... group by SalesOrder,...

Regards,

Mukesh

Not applicable
Author

Hi Mukesh,

It is not working. Can you upload .Qvw file ?

senpradip007
Specialist III
Specialist III

Could you please explain your requirement

Sales OrderCustomer IDSerial NumberNet Value
102000012031001230
23
344
33
667
111
3212

On which basis 3212 value would come ?

Not applicable
Author

That is each and every Part.No Values(Rates) based on Serial Number.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

The maximum values are subtotals. You should not load these, rather let QV calculate the totals. Or load only the subtotals and not the detail if that is what you require. What you should not do is load both as every expression in your data model will be more complex and (if your data set is large) may perform very badly.

This script will exclude the subtotals:

Pre:

LOAD [Sales Order],

    [Customer ID],

    [Serial Number],

    [Net Value],

    RowNo() As RowID

FrOM

(ooxml, embedded labels, table is Sheet1, filters(

Replace(1, top, StrCnd(null)),

Replace(2, top, StrCnd(null)),

Replace(3, top, StrCnd(null))

));

Final:

NoConcatenate

LOAD [Sales Order],

    [Customer ID],

    [Serial Number],

    [Net Value],

    RowID

Resident Pre

Where [Sales Order] = Previous([Sales Order])

  AND [Customer ID] = Previous([Customer ID])

  AND ([Serial Number]) = Previous ([Serial Number])

Order By RowID DESC;

DROP Table Pre;

Now you can use display the data in a straight table with  [Sales Order],  [Customer ID], [Serial Number] as dimensions and Sum([Net Value]) in an expression.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein