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 All,
I wrote below measure to be able to display only current users records in the dashboard:
LoggedInUserIsPm =
VAR CurrentUser = USERPRINCIPALNAME()
VAR LoggedInUserEmail =
DISTINCT(SELECTCOLUMNS(
FILTER(PM_Table, PM_Table[EMPLOYEE_USER_PRINCIPAL_NAME] = CurrentUser), "EMPLOYEE_E_MAIL", [EMPLOYEE_E_MAIL]))
VAR IsPm = ISEMPTY(CALCULATETABLE(ReportTable, ReportTable[project_manager_email] = LoggedInUserEmail ))
VAR countMatchRows = COUNTROWS(CALCULATETABLE(ReportTable, ReportTable[project_manager_mail] = LoggedInUserEmail ))
Return
"Email: " &LoggedInUserEmail&" IsPm? "& IsPm &" CountMatchingRows "& countMatchRows
Outcome - Email: IsPm? False CountMatchingRows 9
There is no matching record in 'PM_Table' for currently logged in user's email address, hence 'LoggedInUserEmail' is blank.
Still ISEMPTY function is returning 'False' and COUNTROWS returning 9 records.
Expected outcome is ISEMPTY should return TRUE. What am I missing here?
Solved! Go to Solution.
Yes, you are right. After posting this query, I noticed that there are 9 records having blank in project manager email. Which matches the outcome of COUNTROWS function.
I was able to get around this issue by modifying the measure as below:
LoggedInUserIsPm =
VAR CurrentUser = USERPRINCIPALNAME()
VAR LoggedInUserEmail =
DISTINCT(SELECTCOLUMNS(
FILTER(PM_Table, PM_Table[EMPLOYEE_USER_PRINCIPAL_NAME] = CurrentUser), "EMPLOYEE_E_MAIL", [EMPLOYEE_E_MAIL]))
VAR IsPm = IF(ISBLANK(LoggedInUserEmail), 0, NOT(ISEMPTY(CALCULATETABLE(ReportTable, ReportTable[project_manager_email] = LoggedInUserEmail )))
Return
1 * IsPm
Thanks for your inputs.
do you have any records where the project manager email is blank?
Yes, you are right. After posting this query, I noticed that there are 9 records having blank in project manager email. Which matches the outcome of COUNTROWS function.
I was able to get around this issue by modifying the measure as below:
LoggedInUserIsPm =
VAR CurrentUser = USERPRINCIPALNAME()
VAR LoggedInUserEmail =
DISTINCT(SELECTCOLUMNS(
FILTER(PM_Table, PM_Table[EMPLOYEE_USER_PRINCIPAL_NAME] = CurrentUser), "EMPLOYEE_E_MAIL", [EMPLOYEE_E_MAIL]))
VAR IsPm = IF(ISBLANK(LoggedInUserEmail), 0, NOT(ISEMPTY(CALCULATETABLE(ReportTable, ReportTable[project_manager_email] = LoggedInUserEmail )))
Return
1 * IsPm
Thanks for your inputs.
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 |
---|---|
106 | |
94 | |
77 | |
65 | |
53 |
User | Count |
---|---|
147 | |
106 | |
104 | |
87 | |
61 |