Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Total Sum in matrix

Hi all,

 

I have a matrix where I calculate a value for each cell, and I need the total to be the sum of the values shown on the matrix. 

 

This is the measure that is being used in the matrix: 

Oportunidade = [Delta KPI]*calculate(SUMX('Reajuste coletivo','Reajuste coletivo'[VL_OBRIGACAO_MES_CONTRATO]),'Reajuste coletivo'[DT_REFERENCIA]="2023")*MEDIAN('Reajuste coletivo'[REAJUSTE])*12/100
 
where Delta KPI = 
CALCULATE('Reajuste coletivo'[% isento],'Reajuste coletivo'[DT_REFERENCIA]="2022")-CALCULATE('Reajuste coletivo'[% isento],'Reajuste coletivo'[DT_REFERENCIA]="2023")
 

 

  • tamerj1's avatar
    tamerj1
    3 years ago

    Anonymous 

    Sorry I missed to wrap MEDIAN with CALCULATE 

     

    Oportunidade =
    SUMX (
    CROSSJOIN ( VALUES ( 'De para filial'[ESTADO] ), VALUES( 'Reajuste coletivo'[Faixa de vidas]) ),
    [Delta KPI]
    * CALCULATE (
    SUMX ( 'Reajuste coletivo', 'Reajuste coletivo'[VL_OBRIGACAO_MES_CONTRATO] ),
    'Reajuste coletivo'[DT_REFERENCIA] = "2023"
    )
    * CALCULATE ( MEDIAN ( 'Reajuste coletivo'[REAJUSTE] ) ) * 12 / 100
    )

7 Replies

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

    please try

    Oportunidade =
    SUMX (
    SUMMARIZE (
    'Reajuste coletivo',
    'Reajuste coletivo'[column in rows of the matrix],
    'Reajuste coletivo'[column in columns of the matrix]
    ),
    [Delta KPI]
    * CALCULATE (
    SUMX ( 'Reajuste coletivo', 'Reajuste coletivo'[VL_OBRIGACAO_MES_CONTRATO] ),
    'Reajuste coletivo'[DT_REFERENCIA] = "2023"
    )
    * MEDIAN ( 'Reajuste coletivo'[REAJUSTE] ) * 12 / 100
    )

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi,

       

      The column in the rows of the matrix is in another table, so the summarize part is not working.

      • tamerj1's avatar
        tamerj1
        Icon for Community Champion rankCommunity Champion

        Anonymous 

        In this case you can use 

        CROSSJOIN ( VALUES ( Table1[Column] ), VALUES ( Table2[Column] ) )

  • Anonymous's avatar
    Anonymous
    Not applicable

    for some reason its still not summing up to the correct values:

     

    Oportunidade =
    SUMX (
    CROSSJOIN ( VALUES ( 'De para filial'[ESTADO] ), VALUES ( 'Reajuste coletivo'[Faixa de vidas]) ),
    [Delta KPI]
    * CALCULATE (
    SUMX ( 'Reajuste coletivo', 'Reajuste coletivo'[VL_OBRIGACAO_MES_CONTRATO] ),
    'Reajuste coletivo'[DT_REFERENCIA] = "2023"
    )
    * MEDIAN ( 'Reajuste coletivo'[REAJUSTE] ) * 12 / 100
    )

     

    • tamerj1's avatar
      tamerj1
      Icon for Community Champion rankCommunity Champion

      Anonymous 

      Sorry I missed to wrap MEDIAN with CALCULATE 

       

      Oportunidade =
      SUMX (
      CROSSJOIN ( VALUES ( 'De para filial'[ESTADO] ), VALUES( 'Reajuste coletivo'[Faixa de vidas]) ),
      [Delta KPI]
      * CALCULATE (
      SUMX ( 'Reajuste coletivo', 'Reajuste coletivo'[VL_OBRIGACAO_MES_CONTRATO] ),
      'Reajuste coletivo'[DT_REFERENCIA] = "2023"
      )
      * CALCULATE ( MEDIAN ( 'Reajuste coletivo'[REAJUSTE] ) ) * 12 / 100
      )
      • Anonymous's avatar
        Anonymous
        Not applicable

        Perfect! Thank you so much