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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
giorgionway
Frequent Visitor

Price calculation from weight range

hello,

is it possible  to calculate sales price (in yellow cell) from PRICES table?

 

 

 

Annotation 2020-05-15 014019.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @giorgionway ,

First, you can create two calculated columns to get min weight and max weight of weight range:

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]) ))

Then create a measure to get the corresponding price:

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

Best Regards

Rena

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @giorgionway ,

First, you can create two calculated columns to get min weight and max weight of weight range:

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]) ))

Then create a measure to get the corresponding price:

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

Best Regards

Rena

Greg_Deckler
Community Champion
Community Champion

You could get there with some fancy string parsing DAX but what I would recommend is that in Power Query, you split your Weight Range into 3 columns. Split on "-" then split the second resulting column on " ". Then you have the mins and maxes in two separate columns and you could do this:

 

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]
  ) 


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors