Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
oxiofrt
Partner - Creator
Partner - Creator

How to calculate a total in a column

Hi,

my table is a crossed one.

First dimension is a simple one, and second dimension is an AGGR one.

I am not able to add a calcultated total for the first dimension, that would not take the second dimension into account.

May you help ? An app is joined in this discussion.

Thanks a lot for you help. !

5 Replies
cesaraccardi
Specialist
Specialist

Hi Franck,

I think you might want to create the "AGGR" dimension on the script. Something like:

LOAD

  DT & '|' & ID_SECTEUR as %AGGR_DIMT,

    DATE_DEPART,

    DATE_DEPART_V,

    DT,

    HEURE,

    ID_CENTRE,

    left (SECTEUR,2) as ID_SECTEUR,

    NB_DEPARTS_ENGINS,

    DH_DEB_DIMT,

    HEURE_DEB_DIMT,

    DH_DEPART,

    FL_SEUIL,

    DH_FIN

FROM [lib://QVD/DIMT.qvd](qvd)

WHERE year(DT) = 2015

and month(DT) = 9

and ID_SECTEUR < 10;

TMP_AGGR_DIMT:

LOAD

  DT & '|' & ID_SECTEUR   as %AGGR_DIMT,

    sum(NB_DEPARTS_ENGINS) as AGGR_NB_DEPARTS_ENGINS,

  max(FL_SEUIL) as AGGR_FL_SEUIL

RESIDENT

  DIMT

GROUP BY

  DT,

    ID_SECTEUR;

AGGR_DIMT:

LOAD

  %AGGR_DIMT,

    SUM(AGGR_NB_DEPARTS_ENGINS * AGGR_FL_SEUIL) as AGGR_NB_DEPARTS_ENGINS

RESIDENT

  TMP_AGGR_DIMT

GROUP BY

  %AGGR_DIMT;

DROP TABLE TMP_AGGR_DIMT;

cesaraccardi
Specialist
Specialist

This way you should be able to do the calculations easily.

oxiofrt
Partner - Creator
Partner - Creator
Author

Thanks for your help.

But calculating it within the script avoid possibilty to use as many combination of filters as it required.

The aim is to have this total without modifying the script.

cesaraccardi
Specialist
Specialist

Hi,


When selections are aplied to other filters they are basically going to narrow down the possibilities for DT and ID_SECTEUR and thus filtering the "AGGR_DMIT" table. So I believe that is not going to be a problem unless these other filters need to be taken into count on the aggregation function depending on selections, is that what you are saying?

oxiofrt
Partner - Creator
Partner - Creator
Author

Yes, exactly !