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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Syndicate_Admin
Administrator
Administrator

Promedio ponderado

Hola

Necesito calcular un promedio ponderado para el precio al consumidor.

Lorenzo_98_0-1625219947885.png

Actualmente, CP YTD se calcula como Average(DB(consumer price). Sin embargo, si utilizo esta fórmula recibo una media aritmética.

Necesito sopesar el precio al consumidor para NES YTD (Ventas).

la fórmula debe ser algo así como: (CP YTD*NES YTD)/sum(NES YTD). sin embargo, necesito hacer eso para cada nivel.

por ejemplo:
para liv6 [(NES Ytd 541... * CP YTD 541... ) / suma (NES YTD 541... + NES YTD 541... y así sucesivamente) ]

el denominador debe ajustarse dinámicamente en función del nivel que se analice.

¿Cómo puedo hacerlo en DAX?

Gracias por la ayuda

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

Intente utilizar la función sumx.

WA = 
VAR total_ = 
    CALCULATE(
        [NES YTD],
        ALL(xxxxx)
    )
VAR _Table = 
    ADDCOLUMNS(
        SUMMARIZE(
            Sales,
            xxx[Row1],xxx[Row2]
        ),
        "nes", [NES YTD],
        "cp", [CP YTD]
    )
RETURN
    SUMX(
        _Table ,
        [cp] * [nes]/total_
    )

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

Gracias por su respuesta!

Sólo tengo algunas preguntas más?

  1. ¿Qué quiere decir con xxx?
    En Var total_ ¿necesito insertar el nombre de la tabla?
  2. en Var _Table es las ventas una tabla nueva o existente?

  3. ¿A qué se refieren Row1 y Row2?

Realmente aprecio su ayuda!

Hace referencia al nombre de columna de las etiquetas de fila. Si el problema persiste, proporcione algunos datos de ejemplo, preferiblemente un pbix después de eliminar los datos confidenciales.

https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...

Syndicate_Admin
Administrator
Administrator

Intente utilizar la función sumx.

WA = 
VAR total_ = 
    CALCULATE(
        [NES YTD],
        ALL(xxxxx)
    )
VAR _Table = 
    ADDCOLUMNS(
        SUMMARIZE(
            Sales,
            xxx[Row1],xxx[Row2]
        ),
        "nes", [NES YTD],
        "cp", [CP YTD]
    )
RETURN
    SUMX(
        _Table ,
        [cp] * [nes]/total_
    )

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors