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
Syndicate_Admin
Administrator
Administrator

La medida se calcula incorrectamente en una tabla

Hola a todos

Agradecería que alguien me ayudara por favor con mis medidas:

Tengo la siguiente tabla:

FechaArtículoPrecio
01.01.2020A20
01.01.2020A25
01.01.2020A30
03.01.2020A20
10.01.2020A35
02.01.2020B50
05.01.2020B60
01.01.2020C40
01.01.2020C45
01.01.2020C50
03.01.2020C40
10.01.2020C45


He calculado el cambio porcentual para cada artículo tomando el precio promedio para el día basado en la segmentación de fecha de la siguiente manera:

Percent Change =
var _max = maxx(Table,Table[Date].[Date])
var _min = MINX(Table,Table[Date].[Date])
return
(CALCULATE(AVERAGE(Table[Price]), FILTER(ALLSELECTED(Table),Table[Date].[Date]=_max))-CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED(Table),Table[Date].[Date]=_min)))/CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED(Price),Table[Date].[Date]=_min))*100

Cuando selecciono elementos individuales, el porcentaje se calcula correctamente entre las fechas mínimas y máximas de la siguiente manera:

Capture.JPG

Pero cuando selecciono todos los artículos, obtengo diferentes cambios porcentuales

Capture1.JPG

¿Puede alguien ayudarme a obtener los cambios porcentuales correctos cuando selecciono todos los elementos (los mismos valores que cuando selecciono un solo elemento)? Me gustaría presentar cambios para todos los elementos de una tabla.

Gracias

1 ACCEPTED SOLUTION

@dashbuilder, he creado tres versiones de la misma, por favor, echa un vistazo a los que están en el archivo adjunto después de la firma

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

@dashbuilder , Crear una tabla de fechas independiente y, a continuación, pruebe la misma fórmula con la tabla de fechas

ejemplo -

Cambio de porcentaje ?
var _max á maxx('DATE','DATE'[Date])
var _min á MINX('DATE','DATE'[Date])
devolución
(CALCULATE(AVERAGE(Table[Price]), FILTER(ALLSELECTED('DATE'),'DATE'[Date]-_max))
-CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED('DATE'),'DATE'[Date]-_min)))/
CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED('DATE'),'DATE'[Date]-_min))*100

Además, utilice la función de división

@amitchandak agradezco su respuesta. He creado una nueva tabla de datos de la siguiente maneraCapture2.JPG

Entonces, alteré la fórmula como se sugiere:

Percent Growth = 
var _max = maxx('DATE','DATE'[Date])
var _min = MINX('DATE','DATE'[Date])
return
DIVIDE((CALCULATE(AVERAGE(Table[Price]), FILTER(ALLSELECTED('DATE'),'DATE'[Date]=_max))
-CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED('DATE'),'DATE'[Date]=_min))),
CALCULATE(AVERAGE(Table[Price]),FILTER(ALLSELECTED('DATE'),'DATE'[Date]=_min)))*100

Ahora, obtengo "0"s:

Capture4.JPG

¿Estoy haciendo algo malo? Gracias montones.

@dashbuilder, he creado tres versiones de la misma, por favor, echa un vistazo a los que están en el archivo adjunto después de la firma

Impresionante, gracias @amitchandak

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.