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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
deizesilveira
New Member

Transform DAX measure into data segmentation

I have a DAX measure that displays Customer Status as "Sem Crescimento", "Com Crescimento", "Sem Histórico", and "Sem Compra". Currently, this measure dynamically characterizes a customer based on their Gross Sales (through DAX) and does not exist as a characterization within a table.

I need a solution to transform this DAX measure into a slicer, where the user can select one of the 4 options in the filter and view in a table visual only the customers that match the status according to the selected filter.

Below is the DAX formula for Customer Status and the two Gross Sales measures that compose this measure:

 

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()))))

Venda Bruta =
CALCULATE( SUMX( FILTER( 'tabela_venda', 'tabela_venda'[ITEM_COM_RECUSA] = "Não"), 'tabela_venda'[VL_LIQUIDO] ) ) + CALCULATE( SUMX( FILTER( 'tabela_venda', 'tabela_venda'[ITEM_COM_RECUSA] = "Sim"), 'tabela_venda'[VL_CAN] ) )

Venda Bruta AnoAnterior =
VAR ColecaoAnterior = [Coleção Anterior]
RETURN CALCULATE([Venda Bruta], ALL(dim_chave[CHAVE_COMERCIAL]), dim_chave[CHAVE_COMERCIAL] = ColecaoAnterior )

Coleção Anterior =
VAR Atual = [Coleção Atual]
VAR Chave = LEFT(Atual, 2) VAR AnoAnterior = RIGHT(Atual, 4) - 1
RETURN Chave & " " & AnoAnterior

Coleção Atual = SELECTEDVALUE(dim_metas[CHAVE_COMERCIAL])

Thank you in advance for your help!

1 REPLY 1
lbendlin
Super User
Super User

Power BI does not support that. You need to bring your own reference table with the expected category values, and then you can base your measure on that table.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.