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
Lucy_Ramirez
Frequent Visitor

Asignar dato por mayor peso

Tengo dos medidas, una que calcula el peso de las ventas por partida (%Peso) y otra que calcula el precio unitario ($Precio Unitario)

Necesito encontrar una medida que me asigne para cada articulo un precio unitario, el precio unitario que necesito tiene que ser el que tenga el mayor % peso por partida.

 

Mi base de datos es la parte azul, mis medidas es la parte verde y las medidas que necesito es la parte café.

 

Lucy_Ramirez_0-1703801768918.png

 

Espero puedan ayudarme.

Muchas gracias!

Saludos 🙂 

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

Hi @Lucy_Ramirez ,

Since it's not clear how your ($Precio Unitario) measure is created, I used a column instead.

Here some steps that I want to share, you can check them if they suitable for your requirement.

Here is my test data:

vheqmsft_0-1704183902904.png

1.Create three measures

%Peso = 
VAR _SUM = CALCULATE(
            SUM('Table'[Ventas]),
            ALLEXCEPT('Table','Table'[Partida])
            )
VAR _value = 
        sum('Table'[Ventas])
RETURN  _value/_SUM
Mayor %Precio por paratida = var _a=[%Peso]
VAR _table = 
    SUMMARIZE(
    ALLEXCEPT('Table',
    'Table'[Partida]),
    "%peso",_a)
RETURN
MAXX(  ALLEXCEPT('Table',
    'Table'[Partida]),[%peso])
Precio Unitario de Mayor% Peso por partida = 
CALCULATE(
    MAX('Table'[$Precio Unitario]),
    FILTER(ALLEXCEPT('Table',
    'Table'[Partida]),
    'Table'[%Peso] = 'Table'[Mayor %Precio por paratida]
    )
)

2.Final output

vheqmsft_1-1704184007436.png

If this is not the outcome you were hoping for. Please provide detailed sample data and ($Precio Unitario) measure-creating processes So that I can help you better.

Best Regards,

Albert He

View solution in original post

2 REPLIES 2
v-heq-msft
Community Support
Community Support

Hi @Lucy_Ramirez ,

Since it's not clear how your ($Precio Unitario) measure is created, I used a column instead.

Here some steps that I want to share, you can check them if they suitable for your requirement.

Here is my test data:

vheqmsft_0-1704183902904.png

1.Create three measures

%Peso = 
VAR _SUM = CALCULATE(
            SUM('Table'[Ventas]),
            ALLEXCEPT('Table','Table'[Partida])
            )
VAR _value = 
        sum('Table'[Ventas])
RETURN  _value/_SUM
Mayor %Precio por paratida = var _a=[%Peso]
VAR _table = 
    SUMMARIZE(
    ALLEXCEPT('Table',
    'Table'[Partida]),
    "%peso",_a)
RETURN
MAXX(  ALLEXCEPT('Table',
    'Table'[Partida]),[%peso])
Precio Unitario de Mayor% Peso por partida = 
CALCULATE(
    MAX('Table'[$Precio Unitario]),
    FILTER(ALLEXCEPT('Table',
    'Table'[Partida]),
    'Table'[%Peso] = 'Table'[Mayor %Precio por paratida]
    )
)

2.Final output

vheqmsft_1-1704184007436.png

If this is not the outcome you were hoping for. Please provide detailed sample data and ($Precio Unitario) measure-creating processes So that I can help you better.

Best Regards,

Albert He

amitchandak
Super User
Super User

@Lucy_Ramirez , Try measure like

 

calculate([%peso], filter(allselected(Table), Table[partida] = max(Table[partida])))

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.