Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Sample data
Table A
Shop | Value | From_year | To_year |
A | 12 | 2019 | 2021 |
A | 345 | 2022 | 2023 |
Table B
Shop | Year |
A | 2020 |
A | 2023 |
I want to create a calculated column [Value_looked_up] in Table B, with the expected result as below:
Table B
Shop | Year | Value_looked_up |
A | 2020 | 12 |
A | 2023 | 345 |
The result is to perform lookup with [shop], returning the relevant [value] when 'Table B'[Year] >= 'Table A'[From_year] and Table B'[Year] <= 'Table A'[To_year].
Any ideas how to do that? I tried LOOKUPVALUE(), but this function seems won't allow boolean logic in its syntax.
Much appreciated for the help.
Solved! Go to Solution.
Thanks for the help, your answer has reminded me of how powerful CALCULATE() is supposed to be.
Was looking into LOOKUPVALUE() while forgetting this can be done by CALCULATE().
And my since my actual data is not numeric, for those who wish to lookup text, please try the following:
Value = CALCULATE(MAX('Tab_A'[Value]),
FILTER('Tab_A',[To year]>=[Year] && [From year]<=[Year])
)
Thanks for the help, your answer has reminded me of how powerful CALCULATE() is supposed to be.
Was looking into LOOKUPVALUE() while forgetting this can be done by CALCULATE().
And my since my actual data is not numeric, for those who wish to lookup text, please try the following:
Value = CALCULATE(MAX('Tab_A'[Value]),
FILTER('Tab_A',[To year]>=[Year] && [From year]<=[Year])
)
User | Count |
---|---|
85 | |
80 | |
77 | |
49 | |
41 |
User | Count |
---|---|
114 | |
56 | |
51 | |
42 | |
42 |