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
SandyBL
Advocate III
Advocate III

Lookup value based on value falling within range on other table

Looking to create the "Actual Rate" column in a table based on a rate card table that has the rules on which rate to use for each volume level.  So need help with the Actual Rate column.  I can do this in Excel but not getting it in PowerBI

 

Table 1: Rare Card

Rate    Min Volume      Max Volume

$5       0                        10,000

$4       10,001                11,000

 

Table 2: Volume Delivered

Actual Volume     Actual Rate

10,500                  $4

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@SandyBL

 

 

ActualRate =
CALCULATE (
    VALUES ( Rates[Rate] ),
    FILTER (
        Rates,
        Rates[Min Volume] <= Volume[Actual Volume]
            && Rates[Max Volume] >= Volume[Actual Volume]
&& Rates[Account]= Volume[Account] ) )



Lima - Peru

View solution in original post

5 REPLIES 5
Vvelarde
Community Champion
Community Champion

@SandyBL

 

Hello, try this in a calculated column in Table2 (Volume)

 

ActualRate =
CALCULATE (
    VALUES ( Rates[Rate] ),
    FILTER (
        Rates,
        Rates[Min Volume] <= Volume[Actual Volume]
            && Rates[Max Volume] >= Volume[Actual Volume]
    )
)



Lima - Peru

 

If I need to write the same query logic in while add custom column in Edit Queries Then how we can write ?

Just realized its more complex than that

 

Table 1: Rare Card

Rate    Account        Min Volume      Max Volume

$5        1                          0                        10,000

$4        1                         10,001                11,000

$8        2                          0                        10,000

$7        2                         10,001                11,000

 

Table 2: Volume Delivered

Account    Actual Volume     Actual Rate

1                   10,500                  $4

 

 

So the rate card table has the same min and max volumes repeated for different accounts, so when using that formula it has mutliple Rates that fall within the same range and I get an error.  How do I filter to look at the specific account first before looking at the range?

Vvelarde
Community Champion
Community Champion

@SandyBL

 

 

ActualRate =
CALCULATE (
    VALUES ( Rates[Rate] ),
    FILTER (
        Rates,
        Rates[Min Volume] <= Volume[Actual Volume]
            && Rates[Max Volume] >= Volume[Actual Volume]
&& Rates[Account]= Volume[Account] ) )



Lima - Peru

Thank you for your help

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.