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
Antara
Helper I
Helper I

División de carreras en la primera fecha

Hola Expertos,
Estaba tratando de crear medida en DAX en los siguientes datos:
Nombre de la tabla: Muestra

fecha de Product_id My_price venta other_price el otro precio indexado
12345 20200701 100 75 120
12345 20200704 100 22 130
12345 20200705 100 56 140
12345 20200706 100 52 140
12345 20200731 100 99 140
12345 20200801 100 24 150
12345 20200809 100 58 120
12345 20200907 100 24 200
12345 20200908 100 39 120
12345 20200908 100 56 100
12345 20200908 100 64 125

Fórmula para otro precio indexadoother_price/first_other_price_in_the_month * 100

A continuación se espera la salida:
fecha de Product_id My_price venta other_price el otro precio indexado
12345 20200701 100 75 120 100
12345 20200704 100 22 130 108.3333333
12345 20200705 100 56 140 116.6666667
12345 20200706 100 52 140 116.6666667
12345 20200731 100 99 140 116.6666667
12345 20200801 100 24 150 100
12345 20200809 100 58 120 80
12345 20200907 100 24 200 100
12345 20200908 100 39 120 60
12345 20200908 100 56 100 50
12345 20200908 100 64 125 62.5


En el ejemplo anterior Para:
Mes de Julio first_other_price_in_the_month-120 (que se utilizará en la fórmula para los datos del mes de julio)
Mes de Agosto first_other_price_in_the_month-150 (para ser utilizado en la fórmula para los datos de Augmonth)
Mes de Septiembre first_other_price_in_the_month 200 (que se utilizará en la fórmula para los datos del mes de septiembre)

Nota: Tengo 100 Product_ID diferentes, en el ejemplo anterior he considerado solamente una product_id.
Cualquier ayuda o sugerencia en el código DAX para rellenar el precio indexado de otro precio sería muy apreciado.
Gracias

5 REPLIES 5
UAV-Test-Pilot
Helper II
Helper II

@Antara puede ver @edhans respuesta a esta misma pregunta aquí: https://community.powerbi.com/t5/Desktop/Runnig-Division/m-p/1268413

Si esto ayudara, apreciaría un Kudos!
Si esto resuelve el problema, por favor márquelo como una solución! 🙂

Gracias @UAV-Test-Pilot por la respuesta rápida. Te lo agradezco mucho. Si en caso de que en caso de que quiera realizar el promedio en la parte superior de la medida a través de la fecha (independientemente de Product_id). ¿Podemos crear una medida media además de esta medida?

En resumen,

Para mostrar la fecha, avg_of_Measure_created_below en un objeto visual de tabla. Si tenemos fecha como 20200701 para 2 Product_ID (digamos 12345 y 56789) y Measure (creado usando la mención de fórmula por @edhans ) como valor 100 y 200 entonces la tabla visual debe mostrar:

Salida:

fecha avg_measure

20200701 150

Cualquier ayuda o sugerencia sería útil

Gracias

Hola @Antara ,

Por favor, intente así:

Cree una columna de mes:

Month = MONTH('Table'[date])

Crear medidas:

Measure = 
VAR first_date =
    MINX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] <= MIN ( 'Table'[date] )
                && 'Table'[Month] = MAX ( 'Table'[Month] )
        ),
        'Table'[date]
    )
VAR first_other_price =
    CALCULATE (
        SUM ( 'Table'[other_price] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Product_id], 'Table'[Month] ),
            'Table'[date] = first_date
        )
    )
RETURN
    DIVIDE ( SUM ( 'Table'[other_price] ) * 100, first_other_price )

AVG = 
AVERAGEX(ALLEXCEPT('Table','Table'[date]),[Measure])

v-xuding-msft_0-1596532003878.png

v-xuding-msft_1-1596532086030.png

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hola @v-xuding-msft

¿Podemos multiplicarlo por ventas antes de tomar promedio, Por ejemplo:

other_price de venta de fechas PRODUCT_ID

10 01-07-2020 100 10

10 02-07-2020 200 20

20 01-07-2020 300 30

20 02-07-2020 400 40

Befor suma de otro precio podemos multiplicar por ventas como AVERAGE(10*100,20*300)/Sum(100+300) para la fecha 01/07/2020

Gracias


Hola @Antara ,

Por favor, intente esto:

sales * other_price = SUM('Table 1'[sales])* SUM('Table 1'[other_price])


AVG = 
var avg_ = AVERAGEX(ALLEXCEPT('Table 1','Table 1'[date]),[sales * other_price])
var totalsales = CALCULATE(SUM('Table 1'[sales]),ALLEXCEPT('Table 1','Table 1'[date]))
return
DIVIDE(avg_,totalsales)

v-xuding-msft_0-1596597103454.png

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.