Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi everyone,
I'm trying to implement user-specific default filtering in my Power BI report based on the logged-in user's email address.
I want each user to see a specific default view (filtered dataset) based on a value from a user table (DIM_USERNAME_SF). This is not related to row-level security – it's simply to show a filtered page relevant to the user by default, without needing any manual filtering.
I have a table DIM_USERNAME_SF that contains user emails and a column called ALLOWED, which stores a value (e.g., unit number) specific to each user.
The main data table (v_SLA_SF) includes a column called MOKED, which should match the ALLOWED value from the user table.
I created a measure to check if the current row matches the logged-in user's allowed value. Here's the DAX:
userUnitFlag :=
VAR UserEmail = USERPRINCIPALNAME()
VAR UserAllowedUnit =
CALCULATE(
MAX(DIM_USERNAME_SF[ALLOWED]),
FILTER(DIM_USERNAME_SF, DIM_USERNAME_SF[EMAIL] = UserEmail)
)
RETURN
IF (UserAllowedUnit = MAX(v_SLA_SF[MOKED]), 1, 0)
This measure works only if I manually apply a visual filter using userUnitFlag = 1.
However, if I try to use this logic to filter visuals dynamically (i.e., without user interaction), the visual displays blank. It seems the DAX is not triggering correctly unless the filter is explicitly set by the user via the slicer or visual-level filter panel.
About the relationship:
There is no active relationship between DIM_USERNAME_SF and v_SLA_SF, as I'm using a calculated measure instead of a column.
I prefer not to use row-level security or dynamic parameters – I simply want the report to behave as if the filter was already applied when the user opens it.
Is there a way to apply this kind of user-based filtering automatically, using just DAX and a user table (without RLS), so that the visuals display the right data by default?
Any ideas on how to make this logic apply without needing manual interaction?
Thank you!
Solved! Go to Solution.
You can use the technique described in https://www.sqlbi.com/articles/customizing-default-values-for-each-user-in-power-bi-reports/ to set default values per user while still allowing them to override the defaults if they so choose.
Hi @dorku
Thank you for being part of the Microsoft Fabric Community.
As highlighted by @johnt75 , the proposed approach appears to effectively address your requirements. Could you please confirm if your issue has been resolved?
If you are still facing any challenges, kindly provide further details, and we will be happy to assist you.
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.
i did, thank you very much for your help
You can use the technique described in https://www.sqlbi.com/articles/customizing-default-values-for-each-user-in-power-bi-reports/ to set default values per user while still allowing them to override the defaults if they so choose.
@dorku You already have a measure userUnitFlag that checks if the current row matches the logged-in user's allowed value. Ensure this measure is correctly defined as follows:
dax
userUnitFlag :=
VAR UserEmail = USERPRINCIPALNAME()
VAR UserAllowedUnit =
CALCULATE(
MAX(DIM_USERNAME_SF[ALLOWED]),
FILTER(DIM_USERNAME_SF, DIM_USERNAME_SF[EMAIL] = UserEmail)
)
RETURN
IF (UserAllowedUnit = MAX(v_SLA_SF[MOKED]), 1, 0)
Since you want the filter to be applied automatically, you need to set this measure as a filter on all relevant visuals. Here’s how you can do it:
Go to each visual where you want the filter to be applied.
In the Visualizations pane, drag the userUnitFlag measure to the Filters on this visual section.
Set the filter condition to userUnitFlag is equal to 1.
Proud to be a Super User! |
|
Hi, thank you for your help!
As I mentioned earlier, the issue is that when I apply the userUnitFlag = 1 filter directly to the visual, the entire chart becomes blank — completely white, with no data at all.
The strange part is that this doesn’t happen when I apply the same filter manually through a slicer or interactively from outside the visual. In that case, it works just fine.
I’m wondering if this might be related to the fact that I’m using a live connection to a Tabular model, but I’m not entirely sure. Any ideas?
Thanks again!
User | Count |
---|---|
16 | |
14 | |
13 | |
12 | |
11 |
User | Count |
---|---|
19 | |
16 | |
15 | |
11 | |
9 |