Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Default Member set to USERNAME() on Tabular model

I have PBIX file with data import model. The report page XXX needs to defualt to a value in the User table based on USERNAME(). However, the user must be able to view all data for other users as well...
  • Anonymous's avatar
    Anonymous
    9 years ago

    By Tabular model I just meant an import data source. I managed to solve this in a satisfactory way though. I made a Yes/No parameter table and added a dropdown slicer filtered to "Yes" to the report, I then Created two measures, one with no filter, and one filtered to USERNAME(), then created this measure to dynamically switch between the two measures, depending on the value in the parameter-table: 

     

    IF (
        HASONEVALUE ( IsCurrentUser[CurrentUser] ); // My Parameter Table
        SWITCH (
            VALUES ( IsCurrentUser[CurrentUser] ); // My Non-filtered SalesQty
            "Yes"; SalesFact[SalesQty(CurrentUser)]; // My USERNAME() filtered SalesQty
            "No"; SalesFact[SalesQty(AllUsers)]
        );
        SalesFact[SalesQty(AllUsers)]
    )

    Now the report will default to the current user, but he can clear the filter on the parameter dropdown slicer to see all users.

     

    It was actually alot more simple than first expected, as I had a little time to get around it :)

     

    Thanks for input though.

     

    RSK