This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Tengo estas tablas:
- Ventas (Tabla de hechos)
- Cliente (dimension)
- Productos (dimension)
- Calendario
Tengo una medida que me identifica si el cliente es un "Cliente con Compra", lo cual significa "Todos los clientes cuya venta agrupada es mayor a 0". Y esto es así porque los filtros pueden cambiar el estadío de un cliente. Ya que en la tabla transaccional existen valores negativos por ciertas casuísticas, pero son valores válidos.
Solved! Go to Solution.
Sí, estas medidas son pesadas porque estás materializando tablas grandes con SUMMARIZECOLUMNS + FILTER + NATURALINNERJOIN, lo que genera mucha presión en el motor (sobre todo en modelos con muchas filas en Ventas).
ClienteConCompra Optimizada = VAR ClientesPositivos = FILTER( VALUES(Cliente[codigo_cliente]), [Total Ventas] > 0 // Asume que tienes esta medida: SUM(Ventas[mnt_venta_real]) ) RETURN COUNTROWS(ClientesPositivos)
O aún mejor (si el contexto lo permite):
ClienteConCompra Optimizada = CALCULATE( DISTINCTCOUNT(Cliente[codigo_cliente]), FILTER( ALL(Cliente[codigo_cliente]), // o VALUES si quieres respetar algunos filtros CALCULATE([Total Ventas]) > 0 ) )
Recomendación fuerte: Crea primero esta medida base (si no la tienes):
Total Ventas = SUM(Ventas[mnt_venta_real])El objetivo es: Número total de (cliente + fecha) donde el cliente es "neto positivo" y ese día tuvo monto > 0.
Versión mucho más eficiente:
CantidadFechaCompra Optimizada = VAR ClientesPositivos = CALCULATETABLE( VALUES(Cliente[codigo_cliente]), [Total Ventas] > 0 ) RETURN CALCULATE( COUNTROWS( SUMMARIZECOLUMNS( Cliente[codigo_cliente], Calendario[Date], "MontoDia", [Total Ventas] ) ), ClientesPositivos, Ventas[mnt_venta_real] > 0 // Filtra solo días positivos )
CantidadFechaCompra Optimizada = VAR ClientesPositivos = CALCULATETABLE( VALUES(Cliente[codigo_cliente]), [Total Ventas] > 0 ) VAR TablaDiasPositivos = CALCULATETABLE( SUMMARIZECOLUMNS( Cliente[codigo_cliente], Calendario[Date], "Monto", [Total Ventas] ), ClientesPositivos, [Total Ventas] > 0 ) RETURN COUNTROWS(TablaDiasPositivos)
CantidadFechaCompra con TREATAS = CALCULATE( COUNTROWS( SUMMARIZECOLUMNS( Cliente[codigo_cliente], Calendario[Date] ) ), TREATAS( CALCULATETABLE(VALUES(Cliente[codigo_cliente]), [Total Ventas] > 0), Cliente[codigo_cliente] ), Ventas[mnt_venta_real] > 0 )
Hi @GoresiDevBI,
It looks like the total per customer might still be influenced by the day-level context, which can affect both correctness and performance.
You could try separating the logic into two steps:
Something like this:
Total Ventas =
SUM ( Cr_segmentacion_sell_out[mnt_venta_real] )
QuantityDatePurchase =
VAR CustomersWithPurchase =
FILTER (
VALUES ( Dim_cliente_dex[cod_cliente_dex] ),
CALCULATE (
[Total Ventas],
ALLSELECTED ( Calendar )
) > 0
)
RETURN
SUMX (
CustomersWithPurchase,
CALCULATE (
COUNTROWS (
FILTER (
VALUES ( Calendar[Date] ),
CALCULATE ( [Total Ventas] ) > 0
)
)
)
)
This approach evaluates the customer total at the period level and the daily sales separately, which might help avoid the issue you were seeing and reduce the need for heavy intermediate tables.
You can try this and see if it aligns with your expected result. Let me know how it behaves on your model.
Thank you!
Hi @GoresiDevBI,
Could you please confirm if your query has been resolved by the provided solutions? This would be helpful for other members who may encounter similar issues.
Thank you for being part of the Microsoft Fabric Community.
Sí, estas medidas son pesadas porque estás materializando tablas grandes con SUMMARIZECOLUMNS + FILTER + NATURALINNERJOIN, lo que genera mucha presión en el motor (sobre todo en modelos con muchas filas en Ventas).
ClienteConCompra Optimizada = VAR ClientesPositivos = FILTER( VALUES(Cliente[codigo_cliente]), [Total Ventas] > 0 // Asume que tienes esta medida: SUM(Ventas[mnt_venta_real]) ) RETURN COUNTROWS(ClientesPositivos)
O aún mejor (si el contexto lo permite):
ClienteConCompra Optimizada = CALCULATE( DISTINCTCOUNT(Cliente[codigo_cliente]), FILTER( ALL(Cliente[codigo_cliente]), // o VALUES si quieres respetar algunos filtros CALCULATE([Total Ventas]) > 0 ) )
Recomendación fuerte: Crea primero esta medida base (si no la tienes):
Total Ventas = SUM(Ventas[mnt_venta_real])El objetivo es: Número total de (cliente + fecha) donde el cliente es "neto positivo" y ese día tuvo monto > 0.
Versión mucho más eficiente:
CantidadFechaCompra Optimizada = VAR ClientesPositivos = CALCULATETABLE( VALUES(Cliente[codigo_cliente]), [Total Ventas] > 0 ) RETURN CALCULATE( COUNTROWS( SUMMARIZECOLUMNS( Cliente[codigo_cliente], Calendario[Date], "MontoDia", [Total Ventas] ) ), ClientesPositivos, Ventas[mnt_venta_real] > 0 // Filtra solo días positivos )
CantidadFechaCompra Optimizada = VAR ClientesPositivos = CALCULATETABLE( VALUES(Cliente[codigo_cliente]), [Total Ventas] > 0 ) VAR TablaDiasPositivos = CALCULATETABLE( SUMMARIZECOLUMNS( Cliente[codigo_cliente], Calendario[Date], "Monto", [Total Ventas] ), ClientesPositivos, [Total Ventas] > 0 ) RETURN COUNTROWS(TablaDiasPositivos)
CantidadFechaCompra con TREATAS = CALCULATE( COUNTROWS( SUMMARIZECOLUMNS( Cliente[codigo_cliente], Calendario[Date] ) ), TREATAS( CALCULATETABLE(VALUES(Cliente[codigo_cliente]), [Total Ventas] > 0), Cliente[codigo_cliente] ), Ventas[mnt_venta_real] > 0 )
Hola @pcoley ,
Muchas gracias por las opciones brindadas, estuve realizando pruebas. Si bien me dan mejores resultados a nivel de tiempo de cálculo en los indicadores. El consumo de CU's en el servidor es mayor. Lo cual no estaría resolviendo el problema.
Saludos
Hi @GoresiDevBI,
May I check if this issue has been resolved? If not, Please feel free to contact us if you have any further questions.
Thank you
Hello @v-abhinavmu ,
Thank you very much for your response. I tried the solution, but it didn't solve the problem. This is because it's only counting records where the day is positive and isn't using the total for the selected period as a filter to include only customers whose total sales for the period are greater than 0.
Hi @GoresiDevBI,
It looks like the total per customer might still be influenced by the day-level context, which can affect both correctness and performance.
You could try separating the logic into two steps:
Something like this:
Total Ventas =
SUM ( Cr_segmentacion_sell_out[mnt_venta_real] )
QuantityDatePurchase =
VAR CustomersWithPurchase =
FILTER (
VALUES ( Dim_cliente_dex[cod_cliente_dex] ),
CALCULATE (
[Total Ventas],
ALLSELECTED ( Calendar )
) > 0
)
RETURN
SUMX (
CustomersWithPurchase,
CALCULATE (
COUNTROWS (
FILTER (
VALUES ( Calendar[Date] ),
CALCULATE ( [Total Ventas] ) > 0
)
)
)
)
This approach evaluates the customer total at the period level and the daily sales separately, which might help avoid the issue you were seeing and reduce the need for heavy intermediate tables.
You can try this and see if it aligns with your expected result. Let me know how it behaves on your model.
Thank you!
Hi @v-abhinavmu , thanks for your contribution. But just like in the previous version, it isn't being evaluated properly.
Hi @GoresiDevBI,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Thank you.
Hi @GoresiDevBI,
Thanks for reaching out to the Microsoft Fabric Community forum.
The performance issue comes from building large intermediate tables with SUMMARIZECOLUMNS and joining them. Since your logic depends on context (customer status changes with filters), a better approach is to evaluate conditions dynamically using CALCULATE and VALUES.
First, filter customers whose total sales are greater than 0 in the current context. Then, for those customers, count only the dates where daily sales are greater than 0. This approach ensures the “Customer with Purchase” condition is evaluated in the current filter context, and then only valid purchase days are counted for those customers.
This avoids unnecessary table materialization, respects filter context (including product-level negative values), and significantly improves performance.
For more details, please go through official documentation:
SUMMARIZECOLUMNS function (DAX) - DAX | Microsoft Learn
DAX overview - DAX | Microsoft Learn
CALCULATE function (DAX) - DAX | Microsoft Learn
VALUES function (DAX) - DAX | Microsoft Learn
I hope this information helps. Please do let us know if you have any further queries.
Thank you
Hi, thank you very much for your comment. Could you give me an example, please? Thank you very much
Hi @GoresiDevBI,
The performance issue comes from creating large intermediate tables using SUMMARIZECOLUMNS and then filtering or joining them, which becomes expensive on large datasets. Instead, the same logic can be evaluated dynamically using VALUES and CALCULATE, avoiding unnecessary table materialization while still respecting filter context (including negative sales at product level).
The optimized measures are:
DAX:
CustomerWithPurchase =
COUNTROWS(
FILTER(
VALUES(Client[codigo_cliente]),
CALCULATE(SUM(Ventas[mnt_venta_real])) > 0
)
)
QuantityDatePurchase =
COUNTROWS(
FILTER(
SUMMARIZE(
Ventas,
Client[codigo_cliente],
'Calendar'[Date]
),
CALCULATE(SUM(Ventas[mnt_venta_real])) > 0 &&
CALCULATE(
SUM(Ventas[mnt_venta_real]),
REMOVEFILTERS('Calendar'),
VALUES(Client[codigo_cliente])
) > 0
)
)
This approach first evaluates customers whose total sales are greater than 0, and then counts only the days where daily sales are greater than 0 for those customers, matching your requirement. It avoids joins and large intermediate tables, resulting in significantly better performance.
I’ve also attached a PBIX file where you can compare the original and optimized measures and validate the improvement using Performance Analyzer.
Power BI Desktop --> Optimize --> Performance Analyzer --> Start Recording --> Refresh Visuals
I hope this information helps. Please do let us know if you have any further queries.
Thank you
Puedes usar una medida y una matriz sencillas para mostrar en una matriz a los clientes que no han realizado ninguna compra.
Step 0: I use these DATA below.
<DATA>
<Customer>
Step 1: I add a relationship below.
Step 1: I make a matrix below.
Step 2: I change the settings for the matrix.
Customers with no purchase history will also be displayed in the matrix.
Hola gracias por el aporte, pero no está relacionado al problema en sí. La duda no es como visualizar clientes sin compras. Sino como optimizar las medidas considerando lo siguiente:
Cliente con compra: Son aquellos clientes cuya venta total es > 0.
Pero cuidado, considera que un cliente puede ser considerado "Con compra" si no aplicas ningún filtro, pero puede ser considerado "Sin compra" si aplicas un filtro por Producto. Considera que existen ventas negativas a nivel cliente-produto.
CantidadFechaCompra: Cantidad de días de compra por cliente en donde las compras de cada día son mayores a 0. Filtrado por solo los Clientes con compra.
Considera que primero se evalúa si el cliente es "Con Compra" a nivel general. Luego, de esos clientes contabilizas solo los días cuya compra total por día fue mayor a 0.
Saludos
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 37 | |
| 28 | |
| 28 | |
| 19 | |
| 18 |
| User | Count |
|---|---|
| 69 | |
| 38 | |
| 32 | |
| 28 | |
| 24 |