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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
deizesilveira
New Member

Transformar medida dax em segmentação de dados

Tenho uma medida dax que apresenta o Status de Cliente "Sem Crescimento", "Com Crescimento", "Sem Histórico" e "Sem Compra". Atualmente essa medida está disposta em uma tabela com outras informações do cliente como nome, Venda Bruta, Venda Bruta Ano Anterior, Variação AA, etc. Preciso de uma solução para transformar essa medida dax em uma segmentação de dados, onde o usuário possa selecionar no filtro uma das 4 opções e visualizar na tabela somente o Status Selecionado.
Já tentei de algumas formas e nenhuma trouxe um resultado coerente e completo.

Abaixo a fórmula dax Status Cliente:

Status Cliente =
VAR VendasAtual = [Venda Bruta]
VAR VendasAnterior = [Venda Bruta AA]

RETURN IF(ISBLANK(VendasAtual) = FALSE() && ISBLANK(VendasAnterior) = FALSE() && VendasAtual > VendasAnterior,
    "COM CRESCIMENTO", IF(VendasAtual = 0 && VendasAnterior > 0, "SEM COMPRA", IF(VendasAtual > 0 && VendasAnterior > 0 && VendasAtual < VendasAnterior"SEM CRESCIMENTO"IF(VendasAnterior = 0 && VendasAtual > 0"SEM HISTÓRICO"BLANK()))))

Agradeço desde já pelo apoio.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @deizesilveira ,

 

first we need create a enter table like:
'DimStatusCliente'

vcgaomsft_0-1719882271244.png

the relationship:

vcgaomsft_1-1719882335655.png

And then create a new measure:

Filter Status Cliente = 
VAR __slicer = ALLSELECTED('DimStatusCliente'[Status Cliente])
VAR __result = IF( [Status Cliente] IN __slicer, 1 )
RETURN
__result

 And then use this measure as the table's filter:

vcgaomsft_2-1719882381607.png

Output:

vcgaomsft_3-1719882412403.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @deizesilveira ,

 

first we need create a enter table like:
'DimStatusCliente'

vcgaomsft_0-1719882271244.png

the relationship:

vcgaomsft_1-1719882335655.png

And then create a new measure:

Filter Status Cliente = 
VAR __slicer = ALLSELECTED('DimStatusCliente'[Status Cliente])
VAR __result = IF( [Status Cliente] IN __slicer, 1 )
RETURN
__result

 And then use this measure as the table's filter:

vcgaomsft_2-1719882381607.png

Output:

vcgaomsft_3-1719882412403.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Muito obrigada pela sugestão!

Mas um ponto importante é que "Status Cliente" não existe em uma estrutura fixa de tabela, é uma medida dax. Quando digo: "Atualmente essa medida está disposta em uma tabela com outras informações do cliente como nome, Venda Bruta, Venda Bruta Ano Anterior, Variação AA, etc." quero dizer que adicionei um visual de tabela e dentro dele coloquei a coluna nome do cliente e as medidas dax criadas, como "Status Cliente", "Venda Bruta", "Venda Bruta Ano Anterior", etc.

Hoje esse Status Cliente é definido através da venda do cliente, vou adicionar as medidas que definem esses Status (Com Crescimento, Sem Crescimento, Sem Histórico e Sem Compra) abaixo (
[Venda Bruta] e [Venda Bruta AA]):

Venda Bruta =
CALCULATE(
    SUMX(
        FILTER(
            'tabela_venda',
            'tabela_venda'[FG_ITEM_COM_RECUSA_COM] = "Não"),
        'tabela_venda'[VL_LIQUIDO_ITEM]
    )
) +
CALCULATE(
    SUMX(
        FILTER(
            'tabela_venda',
            'tabela_venda'[FG_ITEM_COM_RECUSA_COM] = "Sim"),
        'tabela_venda'[VL_CAN_TOT]
    )
)

 

Venda Bruta AA =
VAR ColecaoAnterior = [Coleção Anterior]

RETURN
    CALCULATE([Venda Bruta],
        ALL(dim_chave[CHAVE_COLECAO_COMERCIAL]),
        dim_chave[CHAVE_COLECAO_COMERCIAL] = ColecaoAnterior
    )
Anonymous
Not applicable

Hi @deizesilveira ,

 

I understand that [Status Cliente] is a measure. 

But since Slicer only accepts columns as values, here I've added all the output values from [Status Cliente] to a table.

Finally a metric is created to get the values in the slicer and pass them to the visual filter.

You may refer to the example file I uploaded earlier.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.