Philip
Philip

Reputation: 2628

Looking up a specific value from a table

I have the below function that works, but what I'm not sure how to do is within the devices table there is a [CreatedBy] column. I want to pull the [UserDeviceType] for the most recent [CreatedBy] row by [user]

How could I modify the below to do this?

UserDeviceType = 
    CALCULATE(
        MAX('devices'[UserDeviceType]),
        FILTER(
            'devices',
            'devices'[user] = 'users'[_id]
        )
    )

Upvotes: 1

Views: 40

Answers (1)

ZygD
ZygD

Reputation: 24478

For calculated column, the following formula works:

UserDeviceType = 
VAR _user = [_id]
VAR _tbl = FILTER(devices, [user] = _user)
VAR _latest = MAXX(_tbl, [CreatedBy])
RETURN MAXX(FILTER(_tbl, [CreatedBy] = _latest), [UserDeviceType])

enter image description here

devices table:
enter image description here

Upvotes: 1

Related Questions