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

Cálculo de precios del rango de peso

Hola

¿es posible calcular el precio de venta (en celda amarilla) a partir de la tabla PRICES?

Annotation 2020-05-15 014019.png

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

Hola @giorgionway ,

En primer lugar, puede crear dos columnas calculadas para obtener el peso mínimo y el peso máximo del rango de peso:

minWeight = value(left('Prices'[Weight Range], SEARCH("-",'Prices'[Weight Range])-1))
maxWeight = value(mid('Prices'[Weight Range],SEARCH("-",'Prices'[Weight Range])+1,SEARCH("k",'Prices'[Weight Range])-2-SEARCH("-",'Prices'[Weight Range]) ))

A continuación, cree una medida para obtener el precio correspondiente:

sPrices = CALCULATE (
    MAX ( 'Prices'[Price] ),
    FILTER (
        'Prices',
        'Prices'[Company] = MAX ( 'Sales'[Company] )
            && 'Prices'[Level] = MAX ( 'Sales'[Level] )
            && 'Prices'[minWeight] <= MAX ( 'Sales'[Weight] )
            && 'Prices'[maxWeight] >= MAX ( 'Sales'[Weight] )
    )
)

getprice.PNG

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hola @giorgionway ,

En primer lugar, puede crear dos columnas calculadas para obtener el peso mínimo y el peso máximo del rango de peso:

minWeight = value(left('Prices'[Weight Range], SEARCH("-",'Prices'[Weight Range])-1))
maxWeight = value(mid('Prices'[Weight Range],SEARCH("-",'Prices'[Weight Range])+1,SEARCH("k",'Prices'[Weight Range])-2-SEARCH("-",'Prices'[Weight Range]) ))

A continuación, cree una medida para obtener el precio correspondiente:

sPrices = CALCULATE (
    MAX ( 'Prices'[Price] ),
    FILTER (
        'Prices',
        'Prices'[Company] = MAX ( 'Sales'[Company] )
            && 'Prices'[Level] = MAX ( 'Sales'[Level] )
            && 'Prices'[minWeight] <= MAX ( 'Sales'[Weight] )
            && 'Prices'[maxWeight] >= MAX ( 'Sales'[Weight] )
    )
)

getprice.PNG

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Podría llegar allí con un DAX de análisis de cadenas elegante, pero lo que recomendaría es que en Power Query, divida su rango de peso en 3 columnas. Dividir en "-" y luego dividir la segunda columna resultante en " ". A continuación, tiene los mins y maxes en dos columnas separadas y podría hacer esto:

Price Column =
  VAR __Company = 'Sales'[Company]
  VAR __Level = 'Sales'[Level]
  VAR __Weight = 'Sales'[Weight]
RETURN
  MAXX(
    FILTER(
      'Prices',
      'Prices'[Company] = __Company && 'Prices'[Level] = __Level &&
        'Prices'[Min Weight Range] <= __Weight && 'Prices'[Max Weight Range] >= __Weight
    ),
    [Price]
  ) 

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.