简体   繁体   中英

Power BI Dax Measure and return multiple columns

I am filtering the data based on the current logged in user using the below query, now I would like to return some of the columns associated with that user - how to achieve that?

In the below case I get only 1 value - I tried to return a complete row but it throws me the error "Multiple columns cannot be converted to a scalar value" - any other way to show multiple columns?

CurrentUserData = VAR CurrentUserState = CALCULATE(MAX(TimeReport[UserPrincipalName]),FILTER(TimeReport, TimeReport[UserPrincipalName] = USERPRINCIPALNAME())) RETURN IF( SELECTEDVALUE(TimeReport[UserPrincipalName]) = CurrentUserState, Values(TimeReport[Neukunden_Akquise_Produkte]) )

Reference: https://community.powerbi.com/t5/Desktop/Show-Current-Logged-in-User-data-only/mp/2219446#M810376

Thanks

Got the solution and credit goes to @miguelarce https://community.powerbi.com/t5/Developer/RLS-vs-Filter-for-current-user/mp/329584

Measure1 WhoIsWatching = USERPRINCIPALNAME() (that is email style usernames, or you can use USERNAME() for windows style users)

在此处输入图像描述

Measure 2 FilterByViewer = IF(selectedvalue(table[email])=[WhoIsWatching],1,0)

在此处输入图像描述

Drag Measure 2 as a filter for visual, select advanced filtering and set it to "Show items when value IS 1"

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM