Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Claudineysilva
Regular Visitor

Criar coluna calculando media de um campo por mês

Necessito de ajuda, neste exemplo a coluna "NovaColuna" deveria calcular a media mesal porem o resultado é igual para todos os meses. Eu espearava que ele calculasse a media mes a mes do campo SLA_DEMANDA_HRS, porem no reslutado ve todos os valores iguais.
Lembrando que todos os dados estão em uma unica tabela(Base_Demandas_CRM). e desta tabela estou criando outra Tabela_Sumarizada.
Abaixo a imagem do resultado:

Claudineysilva_0-1714068155617.png


E como fiz no excel : =SEERRO(MÉDIASES(Base_Demandas_CRM[SLA_DEMANDAS_HORAS];Base_Demandas_CRM[MESABERTURA];A2;Base_Demandas_CRM[ENCERRADA];"N";Base_Demandas_CRM[CODPROCESSO];78);"")




Tabela_Sumarizada =
ADDCOLUMNS (
    SUMMARIZECOLUMNS (
        Base_Demandas_CRM[DTAberturaDemandaREF],  -- Mês da data de abertura
        "DemandasAbertas",
            CALCULATE(
                COUNTROWS(Base_Demandas_CRM),
                Base_Demandas_CRM[CODPROCESSO] = 78
            ),  -- Contagem de demandas abertas com CODPROCESSO = 78
        "DemandasEncerradas",
            CALCULATE(
                COUNTROWS(Base_Demandas_CRM),
                Base_Demandas_CRM[CODPROCESSO] = 78,
                Base_Demandas_CRM[ENCERRADA] = "S"
            )  -- Contagem de demandas encerradas com CODPROCESSO = 78 e ENCERRADA = "S"
    ),
    "Diferenca", [DemandasAbertas] - [DemandasEncerradas],
    "NovaColuna",
    IFERROR(
        AVERAGEX(
            FILTER(
                Base_Demandas_CRM,
                Base_Demandas_CRM[ENCERRADA] = "N" &&
                Base_Demandas_CRM[CODPROCESSO] = 78 &&
                Base_Demandas_CRM[DTAberturaDemandaREF] = MAX(Base_Demandas_CRM[DTAberturaDemandaREF])
            ),
            Base_Demandas_CRM[SLA_DEMANDA_HRS]
        ),
        BLANK()
    )
)
1 ACCEPTED SOLUTION
v-zhengdxu-msft
Community Support
Community Support

Hi @Claudineysilva 

 

The issue caused by this row:

vzhengdxumsft_0-1714098149136.png

In the table view, MAX() can not be used to extract the current value, instead of, you can use earlier() to filter the row:

Plz try this:

Tabela_Sumarizada =
ADDCOLUMNS (
    SUMMARIZECOLUMNS (
        Base_Demandas_CRM[DTAberturaDemandaREF],
        -- Mês da data de abertura
        "DemandasAbertas",
            CALCULATE (
                COUNTROWS ( Base_Demandas_CRM ),
                Base_Demandas_CRM[CODPROCESSO] = 78
            ),
        -- Contagem de demandas abertas com CODPROCESSO = 78
        "DemandasEncerradas",
            CALCULATE (
                COUNTROWS ( Base_Demandas_CRM ),
                Base_Demandas_CRM[CODPROCESSO] = 78,
                Base_Demandas_CRM[ENCERRADA] = "S"
            ) -- Contagem de demandas encerradas com CODPROCESSO = 78 e ENCERRADA = "S"
    ),
    "Diferenca", [DemandasAbertas] - [DemandasEncerradas],
    "NovaColuna",
        IFERROR (
            AVERAGEX (
                FILTER (
                    Base_Demandas_CRM,
                    Base_Demandas_CRM[ENCERRADA] = "N"
                        && Base_Demandas_CRM[CODPROCESSO] = 78
                        && Base_Demandas_CRM[DTAberturaDemandaREF]
                            = EARLIER ( Base_Demandas_CRM[DTAberturaDemandaREF] )
                ),
                Base_Demandas_CRM[SLA_DEMANDA_HRS]
            ),
            BLANK ()
        )
)

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-zhengdxu-msft
Community Support
Community Support

Hi @Claudineysilva 

 

The issue caused by this row:

vzhengdxumsft_0-1714098149136.png

In the table view, MAX() can not be used to extract the current value, instead of, you can use earlier() to filter the row:

Plz try this:

Tabela_Sumarizada =
ADDCOLUMNS (
    SUMMARIZECOLUMNS (
        Base_Demandas_CRM[DTAberturaDemandaREF],
        -- Mês da data de abertura
        "DemandasAbertas",
            CALCULATE (
                COUNTROWS ( Base_Demandas_CRM ),
                Base_Demandas_CRM[CODPROCESSO] = 78
            ),
        -- Contagem de demandas abertas com CODPROCESSO = 78
        "DemandasEncerradas",
            CALCULATE (
                COUNTROWS ( Base_Demandas_CRM ),
                Base_Demandas_CRM[CODPROCESSO] = 78,
                Base_Demandas_CRM[ENCERRADA] = "S"
            ) -- Contagem de demandas encerradas com CODPROCESSO = 78 e ENCERRADA = "S"
    ),
    "Diferenca", [DemandasAbertas] - [DemandasEncerradas],
    "NovaColuna",
        IFERROR (
            AVERAGEX (
                FILTER (
                    Base_Demandas_CRM,
                    Base_Demandas_CRM[ENCERRADA] = "N"
                        && Base_Demandas_CRM[CODPROCESSO] = 78
                        && Base_Demandas_CRM[DTAberturaDemandaREF]
                            = EARLIER ( Base_Demandas_CRM[DTAberturaDemandaREF] )
                ),
                Base_Demandas_CRM[SLA_DEMANDA_HRS]
            ),
            BLANK ()
        )
)

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors