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.
Hola
Esperando que alguien pueda ayudar, ya que no puedo encontrar ninguna información sobre esto...
Quiero calcular el precio medio de algunos datos agregados previamente - No tengo acceso a los datos de nivel de línea.
Una tabla simplificada tiene este aspecto:
Gasto total | Cantidad | Precio |
25 | 5 | 5 |
20 | 2 | 10 |
40 | 10 | 4 |
Esto debería dar una mediana de 4. Pero, ¿cómo escribo ese cálculo?
Gracias de antemano
Solved! Go to Solution.
@s45kougo - Aquí hay una solución mucho más elegante, Página 32, Tabla (32) de PBIX adjunto a continuación sig.
Measure 32 =
VAR __Table =
GENERATE(
'Table (32)',
VAR __Quantity = [Quantity]
RETURN GENERATESERIES(1,__Quantity,1)
)
RETURN
MEDIANX(__Table,[Price])
@s45kougo - Aquí hay una solución mucho más elegante, Página 32, Tabla (32) de PBIX adjunto a continuación sig.
Measure 32 =
VAR __Table =
GENERATE(
'Table (32)',
VAR __Quantity = [Quantity]
RETURN GENERATESERIES(1,__Quantity,1)
)
RETURN
MEDIANX(__Table,[Price])
Oh wow, you are amazing , thank you *so* much! This works perfectly. I thought it must be possible, but I had no idea how to disaggregate a table. Hope this helps someone else too in the future 🙂
@s45kougo - Puede haber una solución más elegante y voy a pensar en ello, pero para esto se podría fuerza bruta:
Measure =
VAR __Table25 =
ADDCOLUMNS(
GENERATESERIES(1,MAXX(FILTER('Table',[Total Spend]=25),[Quantity]),1),
"Price",MAXX(FILTER('Table',[Total Spend]=25),[Price])
)
VAR __Table20 =
ADDCOLUMNS(
GENERATESERIES(1,MAXX(FILTER('Table',[Total Spend]=20),[Quantity]),1),
"Price",MAXX(FILTER('Table',[Total Spend]=20),[Price])
)
VAR __Table40 =
ADDCOLUMNS(
GENERATESERIES(1,MAXX(FILTER('Table',[Total Spend]=40),[Quantity]),1),
"Price",MAXX(FILTER('Table',[Total Spend]=40),[Price])
)
VAR __Table = UNION(__Table25,__Table20,__Table40)
RETURN
MEDIANX(__Table,[Price])
@s45kougo , en caso de que estos datos ya estén agregados. Puede promediar
Promedio: División(Suma(Tabla[Gasto total]),sum(Tabla[Cantidad]))
Que serán cinco
Puede probar MEDIAN( Table[Price] )
Pero dudo que puedas conseguir 4
@amitchandak thanks for trying, but I do want the actual median of 4... I'm guessing that somehow I have to calculate a table that dis-aggregates, but not sure how to do this.
Hola @s45kougo ,
Usted puede tratar de encontrar el percentil 50
Utilice la función
https://dax.guide/percentile-exc/
saludos
Harsh Nathani
¿He respondido a tu pregunta? ¡Marca mi puesto como una solución! Apreciar con un Kudos!! (Haga clic en el botón Pulgares arriba)
Thanks for your reply - unfortunately that also needs the data to be line-level.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |