PowerBI Dax Query - Match a Value and get its Maximum Value

I want to match the value in Column1 of one table with another and get the maximum value of column2.

For Example I have two tables,

Table 1

Col1 Col2
AA   17  
AA   20
AB   10
AB   21

Table 2

Col1 Col2
AA   ?
AB   ?

I want my output to look like this,

Col1 Col2
AA    20
AB    21

I have tried,

Col2 = Max(Table1[col2])

but it didn't help. Thanks. Please share your thoughts.

Upvotes: 0

Views: 589

Answers (1)

Foxan Ng
Foxan Ng

Reputation: 7151

You can use the following DAX:

Col2 = 
CALCULATE(
    MAX(Table1[Col2]),
    FILTER(
        Table1,
        Table1[Col1] = Table2[Col1]
    )
)

Result:

result

Upvotes: 1

Related Questions