Power BI Data Access, Transformation and Cleansing

Please login or click SIGN UP FOR FREE to create your PowerBIUG account to join this user group.
 View Only
  • 1.  Dax Measure and return multiple columns

    Posted Dec 03, 2021 11:49 PM

    Hello Folks,

    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])
    )
     
    Thanks


    ------------------------------
    F Mourtaza
    ------------------------------


  • 2.  RE: Dax Measure and return multiple columns

    Posted Dec 06, 2021 01:14 AM

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


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

    fmourtaza_0-1638770845718.png

     


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

    fmourtaza_1-1638770915538.png

     


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

    fmourtaza_2-1638770961734.png



    ------------------------------
    F Mourtaza
    ------------------------------