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

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
mendes094
Contributor III
Contributor III

Create a measure using count, if and sum in the same expression

Hello, 

I need to create a master item measure that calculates how many values ​​of the master item measure Supply Priority have the value 'Zero'.

The master item measure of Supply Priority is: 

if(SUM(ABASTECIMENTO_COTA) <= 0, 'Sem Cota',

if((SUM(ABASTECIMENTO_COTA) + Sum(ESTOQUE_IDEAL_COTA)) < (SUM(QT_FAT) + [POSICIONADO] + [TRANSITO_AB] + [PROGRAMADO_AB]), 'Extra Meta',

if(SUM(ABASTECIMENTO_COTA) > 0 AND [POSICIONADO] = 0 AND [TRANSITO_AB] = 0 AND [PROGRAMADO_AB] = 0, 'Zero',

IF(SUM(ABASTECIMENTO_COTA) > 0 AND [POSICIONADO] = 0 AND [TRANSITO_AB] + [PROGRAMADO_AB] > 0, 'Rompido',

if((Sum(ESTOQUE_IDEAL_COTA) + CARTEIRA_CD) - ([POSICIONADO] + [TRANSITO_AB] + [PROGRAMADO_AB]) < 0, 'Acima Ideal', 'Abaixo Ideal')))))

 

Note: POCISIONADO, TRANSITO_AB and PROGRAMADO_AB are also master item measure.


I try something like this, but doesn't work: 
Count(Aggr(
If(Sum(ABASTECIMENTO_COTA) > 0 AND POSICIONADO = 0 AND
TRANSITO_AB = 0 AND PROGRAMADO_AB = 0, DFU_COTA), DFU_COTA))

and

 

Count(If(SUM(ABASTECIMENTO_COTA) > 0 AND [POSICIONADO] = 0 AND [TRANSITO_AB] = 0 AND [PROGRAMADO_AB] = 0, DFU_COTA))

 

Anybody can help me?

 

tks!

Labels (3)
1 Solution

Accepted Solutions
Chanty4u
MVP
MVP

Try this 

Count(

    Aggr(

        If(

            SUM(ABASTECIMENTO_COTA) > 0 

            AND [POSICIONADO] = 0 

            AND [TRANSITO_AB] = 0 

            AND [PROGRAMADO_AB] = 0, 

            DFU_COTA

        ), 

        DFU_COTA

    )

)

View solution in original post

2 Replies
Chanty4u
MVP
MVP

Try this 

Count(

    Aggr(

        If(

            SUM(ABASTECIMENTO_COTA) > 0 

            AND [POSICIONADO] = 0 

            AND [TRANSITO_AB] = 0 

            AND [PROGRAMADO_AB] = 0, 

            DFU_COTA

        ), 

        DFU_COTA

    )

)

diegozecchini
Specialist
Specialist

Hi! Alternatively 

If DFU_COTA is already a distinct dimension in your dataset, you may not need Aggr():

Count(

  DISTINCT If(

                  SUM(ABASTECIMENTO_COTA) > 0 AND
                  [POSICIONADO] = 0 AND
                  [TRANSITO_AB] = 0 AND
                 [PROGRAMADO_AB] = 0, DFU_COTA

   )

)