Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
Looking for a measure to show the users who could either have ENFORCED or ENABLED in the same column and table, Can someone please advise?
Solved! Go to Solution.
If you only have those two statuses in the list, you can simply count the rows of the table and filter to only show users with 2 rows present.
If you have more statuses, this measure will do the trick in a list view like this:
_User is both enabled and enforced =
CALCULATE(
COUNTROWS('Table'),
FILTER('Table',
'Table'[Status] = "ENFORCED" ||
'Table'[Status] = "ENABLED"
)
)
When only showing users, not their statuses, the measure above will calculate 2 rows for each user with both ENFORCED and ENABLED as statuses.
However this does not work if you intend to also show the status in the list, as the row will go back to 1 again for all.
Another solution would be to create a separate User table for all your distinct users.
Create a calculated table like this:
Users = DISTINCT('Table'[User])
You can then create a calculated column that will turn true or false if the user has both of these statuses:
IsBothEnabledAndEnforced =
// Count how many rows the user has that is either enforced or enabled
CALCULATE(
COUNTROWS('Table'),
FILTER('Table',
Users[User] = 'Table'[User] &&
OR(
'Table'[Status] = "ENFORCED",
'Table'[Status] = "ENABLED"
)
)
)
// Claim it's equal to 2, meaning it will turn true for any users with both statuses
= 2
Create a relationship between your tables like this:
Create your list using the User from the dimensional table of users and the status from the other table. Use your column from the user table as filter to only show those with both statuses
If you only have those two statuses in the list, you can simply count the rows of the table and filter to only show users with 2 rows present.
If you have more statuses, this measure will do the trick in a list view like this:
_User is both enabled and enforced =
CALCULATE(
COUNTROWS('Table'),
FILTER('Table',
'Table'[Status] = "ENFORCED" ||
'Table'[Status] = "ENABLED"
)
)
When only showing users, not their statuses, the measure above will calculate 2 rows for each user with both ENFORCED and ENABLED as statuses.
However this does not work if you intend to also show the status in the list, as the row will go back to 1 again for all.
Another solution would be to create a separate User table for all your distinct users.
Create a calculated table like this:
Users = DISTINCT('Table'[User])
You can then create a calculated column that will turn true or false if the user has both of these statuses:
IsBothEnabledAndEnforced =
// Count how many rows the user has that is either enforced or enabled
CALCULATE(
COUNTROWS('Table'),
FILTER('Table',
Users[User] = 'Table'[User] &&
OR(
'Table'[Status] = "ENFORCED",
'Table'[Status] = "ENABLED"
)
)
)
// Claim it's equal to 2, meaning it will turn true for any users with both statuses
= 2
Create a relationship between your tables like this:
Create your list using the User from the dimensional table of users and the status from the other table. Use your column from the user table as filter to only show those with both statuses
@Anonymous - Sorry for not responding earlier, just got to it today. What if the I have two columns of names, as first name and last name instead of just user? Please advise.
There are 2 ways I would do this.
1. I simply concatinate the first and last name into a new column and make the new table based on these distinct values
2. Using Selectcolumns-formula you can create the new user table with distinct values from both first and last name in separate columns
Some user could have both enforced or enabled and some could have just one.
What do you need the measure for? Can't you just drop the users in a visual table on the canvas and apply a filter by draging the Status-field to the Filter-pane and select Enforced or Enabled?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |