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
Anonymous
Not applicable

LOOKUPVALUE and Filters

Hi, can you help me pls.

I can't find anything in this area

Еhere are 2 tables without any relationship.
I need to put the price from the first table to the second if Shop and Prod_Id matched.
But the problem is - that at the pricing table, we have different dates. and the date from the second table - should be >= maximum date - from the first. 

Thank you in advance.

 

download (1).png

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

Hi, @Anonymous 

“LOOKUPVALUE” function is not the right direction here. We can use a measure as below to work on it.

Price = 
VAR maxdate =
    CALCULATE (
        MAX ( Price[Date(when start work with this price)] ),
        FILTER (
            Price,
            Price[Shop] = Customer[Shop]
                && Price[Prod_id] = Customer[Prod_id]
                && Price[Date(when start work with this price)] < Customer[Date]
        )
    )
RETURN
    CALCULATE (
        MAX ( Price[Price] ),
        FILTER (
            Price,
            Price[Date(when start work with this price)] = maxdate
                && Price[Shop] = Customer[Shop]
                && Price[Prod_id] = Customer[Prod_id]
        )
)

Here’s a sample I made:

1.png2.png

 

url: https://wicren-my.sharepoint.com/:u:/g/personal/michael_wicren_onmicrosoft_com/EYlU9eRqfdlPtjMm34AdjykBW3Om0nqXfSSkKF-MfSGaVA?e=EOZi6Y

 

Best Regards,
Community Support Team _ Eason
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-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

“LOOKUPVALUE” function is not the right direction here. We can use a measure as below to work on it.

Price = 
VAR maxdate =
    CALCULATE (
        MAX ( Price[Date(when start work with this price)] ),
        FILTER (
            Price,
            Price[Shop] = Customer[Shop]
                && Price[Prod_id] = Customer[Prod_id]
                && Price[Date(when start work with this price)] < Customer[Date]
        )
    )
RETURN
    CALCULATE (
        MAX ( Price[Price] ),
        FILTER (
            Price,
            Price[Date(when start work with this price)] = maxdate
                && Price[Shop] = Customer[Shop]
                && Price[Prod_id] = Customer[Prod_id]
        )
)

Here’s a sample I made:

1.png2.png

 

url: https://wicren-my.sharepoint.com/:u:/g/personal/michael_wicren_onmicrosoft_com/EYlU9eRqfdlPtjMm34AdjykBW3Om0nqXfSSkKF-MfSGaVA?e=EOZi6Y

 

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

Anonymous
Not applicable

Hi, @v-easonf-msft 

Thank you so much. It works perfectly. 
You rock!!!!

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.