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

Lookup Result Based on Range from Another Table

Hi All,

 

Need some help on a Calculated Column I am trying to create. I have two tables, one called 'sales', which is used in this DAX formula to calculate a sales order line level sales price (Column 'Line ASP'). The second, called 'Price List Updated', contains Item Numbers and multiple price "levels" defined by a min and mix (Columns 'Price Level', 'Lowest Price' and 'Highest Price' in that order).

 

Here is the 'sales' table, filtered to the issue I am referring to, where for some reason multiple results are returning null values, but others are not, even though the 'Line ASP' and 'ItemNumber' columns are the same.

 

ItemNumberInvoiceNumberqty$'sLine ASPLine Price Level
LF192341689226$2,280380 
LF192341676896$2,280380 
LF192341676596$2,280380 
LF192341676596$2,280380 
LF192341667386$2,280380 
LF192341512956$2,280380 
LF192341492806$2,280380 
LF192341484466$2,280380Level 6 Price
LF192341087906$2,280380Level 6 Price
LF192344233336$2,190365Level 7 Price
LF192344233316$2,400400 
LF192344182526$2,280380 
LF192344065286$2,400400Level 3 Price

 

Here is my 'Price List Updated' table:

 

Item NumberPrice LevelLowest PriceHighest Price
LF1923Level 10 Price$335.73$353.4
LF1923Level 9 Price$353.4$360.
LF1923Level 8  Price$360.$365.
LF1923Level 7 Price$365.$380.
LF1923Level 6 Price$380.$385.
LF1923Level 5 Price$385.$390.
LF1923Level 4 Price$390.$400.
LF1923Level 3 Price$400.$415.
LF1923Level 2 Price$415.$430.
LF1923Level 1 Price$430. 

 

My DAX is as follows. I wouldn't expect to see null values in my 'sales' table, given that it is "joined" on the Item Number and Level Price range. Any help would be appreciated!

 

Line Price Level =
CALCULATE (
    VALUES ( 'Price List Updated'[Price Level] ),
    FILTER (
        'Price List Updated',
        'Price List Updated'[Item Number] = 'sales'[ItemNumber]
            && NOT ISBLANK ( sales[Line ASP] )
                && sales[Line ASP] >= 'Price List Updated'[Lowest Price]
                && sales[Line ASP] < COALESCE ( 'Price List Updated'[Highest Price], 999999 )
    )
)
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Could you please try the below for creating a calculated column?

 

Line Price Level =
SUMMARIZE (
    FILTER (
        'Price List Updated',
        'Price List Updated'[Item Number] = 'sales'[ItemNumber] --           && NOT ISBLANK ( sales[Line ASP] )
            && sales[Line ASP] >= 'Price List Updated'[Lowest Price]
            && sales[Line ASP] < COALESCE ( 'Price List Updated'[Highest Price], 999999 )
    ),
    'Price List Updated'[Price Level]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

Could you please try the below for creating a calculated column?

 

Line Price Level =
SUMMARIZE (
    FILTER (
        'Price List Updated',
        'Price List Updated'[Item Number] = 'sales'[ItemNumber] --           && NOT ISBLANK ( sales[Line ASP] )
            && sales[Line ASP] >= 'Price List Updated'[Lowest Price]
            && sales[Line ASP] < COALESCE ( 'Price List Updated'[Highest Price], 999999 )
    ),
    'Price List Updated'[Price Level]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.