variable
variable

Reputation: 9724

How to get 1 value from DAX FILTER?

I have Users table containing user_email, user_name, user_category.

The following DAX filter returns a table:

FILTER(Users,[User_Email] = userprincipalname())

I want to get the user_category.

1 approach is SELECTEDCOLUMNS( FILTER(Users,[User_Email] = userprincipalname()), "User_category", [User_Category] ). This returns the result as a column.

Is there any alternate approach to return just 1 value? For example:

SELECTEDVALUE ( SELECTEDCOLUMNS( FILTER(Users,[User_Email] = userprincipalname()), "User_category", [User_Category] ) )

OR

VALUES ( SELECTEDCOLUMNS( FILTER(Users,[User_Email] = userprincipalname()), "User_category", [User_Category] ) )

Upvotes: 0

Views: 7308

Answers (2)

Alexis Olson
Alexis Olson

Reputation: 40244

You can do this with CALCULATE assuming you don't expect there to be multiple values to choose from (if there are, this will return a blank).

CALCULATE (
    SELECTEDVALUE ( Users[User_Category] ),
    FILTER ( Users, Users[User_Email] = userprincipalname() )
)

Upvotes: 1

Angelo Canepa
Angelo Canepa

Reputation: 1791

You can use MAXX on the table generated by FILTER.

MAXX(
       FILTER(Users,[User_Email] = userprincipalname()),
       [User_Category]
)

Upvotes: 2

Related Questions