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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MrMP
Helper III
Helper III

Medir los totales incorect usando IF

Hola a todos,

Vi este problema muchas veces, pero no puedo parecer solucionarlo.

Estoy trabajando con datos de ventas (jerarquía de productos, clientes, ubicaciones, etc.). Actualmente el modelo tiene 2 calendarios. Uno activo y segundo inactivo utilizado para comparar dos períodos de tiempo.

El problema principal es la medida que tiene la declaración IF dentro y donde los totales no están funcionando.

medida: IF(OR(price using calendar 1-0,price using calendar 2-0),
0,
(precio del calendario 1 precio del calendario 2)*cantidad del calendario 1.

Medir desde el calendario 2 está utilizando USERELATIONSHIP y funciona bien.

Cuando uso datos en tablas, me da buenos datos por fila. El problema es con totales y no puedo encontrar una solución alternativa para IF.

¡Gracias!

1 ACCEPTED SOLUTION
v-diye-msft
Community Support
Community Support

Hola @MrMP

Usted puede probar algo como:

CALCBF_New =
VAR _table =
    SUMMARIZE ( Table1, Table1[column], "_Value", [measure] )
RETURN
    IF ( HASONEVALUE ( Table1[column] ), [measure], SUMX ( _table, [_Value] ) )

Community Support Team _ Dina Ye
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

4 REPLIES 4
v-diye-msft
Community Support
Community Support

Hola @MrMP

Usted puede probar algo como:

CALCBF_New =
VAR _table =
    SUMMARIZE ( Table1, Table1[column], "_Value", [measure] )
RETURN
    IF ( HASONEVALUE ( Table1[column] ), [measure], SUMX ( _table, [_Value] ) )

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Greg_Deckler
Super User
Super User

@MrMP Esto parece un problema de totales de medida. Muy común. Vea mi post al respecto aquí: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Además, esta Medida Rápida, Medir Totales, La Palabra Final debe obtener lo que necesita:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@MrMP , En el caso de las medidas, el contexto de la fila reproduce una fila y el total general se calcula de nuevo.

Por lo tanto, cuando se utiliza el mismo contexto en total general, puede pasar por alto ese valor y el total no será el mismo.

Es por eso que obligamos a un total a ser recalculado desde el nivel de fila usando valores o resumiendo

Sumx(Values(Table[Group By]), [Measure])

Sumx(summarize( Table, Table[Group By], "_1", [Measure]),[_1])

referir estos estos

https://www.youtube.com/watch?v=ufHOOLdi_jk
https://www.youtube.com/watch?v=Rii_6qkLNh8
https://www.youtube.com/watch?v=Ka7Ds4EAjNQ

AllisonKennedy
Super User
Super User

Para solucionar este problema, me parece que ayuda si rompes las piezas en pedazos y añades cada una de ellas a tu mesa con totales activados. Así que agregue El precio usando el calendario 1, el precio usando el calendario 2, la cantidad del calendario 1 todo a la tabla junto con los totales.
Para solucionarlo, puede corregir cada una de esas partes para que tengan el total que espera, o puede corregir la instrucción IF.
De cualquier manera, es probable que necesite usar un SUMX para calcular fila por fila y, a continuación, aplicar la suma de cada resultado como las tablas. Intente hacer suMX(tabla de hechos, IF( .... )) como punto de partida.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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