Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
dccosta
Frequent Visitor

Obtaining a column value based on two other columns' values

So essentially I have a table 1 with budget data:

 

Flight date | Year | Budget Version | ammount

01/01 | 2023 | V1 | 1312

02/01 | 2023 | V1 | 1245

07/02 | 2023 | V2 | 2525

10/08 | 2023 | V3 | 2523

01/10 | 2023 | V4 | 724

01/01 | 2024 | V1 | 1341

 

And another table 2 with:

 

Year | Budget Version | Order

2023 | V1 | 1

2023 | V2 | 2

2023 | V3 | 3

2023 | V4 | 4

2024 | V1 | 5

 

The Order field is meant to tell the system which budget version is current/latest, which, for a specific year, is the maximum value of "order". So for example, for 2023, the current forecast version is V4, but for 2024, the current forecast version is V1.

 

I want to be able to have a dynamic measure (or calculated column) that can tell me, based on table 1's "Year", which is the current/latest forecast version, regardless of its original budget version. So for example, if I choose Table 1's registry 01/01 | 2023 | V1 | 1312, this new measure/column would say: "V4", because for the year 2023, it's the last of the versions currently available in table 2.

 

Hope I made myself clear...:)

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @dccosta ,

 

try like:

Measure =
VAR _year = SELECTEDVALUE(table1[Year])
VAR _result =
MAXX(
    TOPN(
         1,
        FILTER(table2, table2[Year]=_year),
        table2[Order]
    ),
    table2[Budget Version]
)
RETURN _result

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @dccosta ,

 

try like:

Measure =
VAR _year = SELECTEDVALUE(table1[Year])
VAR _result =
MAXX(
    TOPN(
         1,
        FILTER(table2, table2[Year]=_year),
        table2[Order]
    ),
    table2[Budget Version]
)
RETURN _result

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.