Forum Discussion

tkfisher's avatar
tkfisher
Frequent Visitor
4 years ago
Solved

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

1 Reply

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