Forum Discussion
Enhancement Request – Add Visit Frequency Count to Employee Location Measure
In the below measure, I am currently retrieving the list of locations/cities visited by each employee.
I would now like to enhance the logic to additionally display how many times the employee visited each respective city/location.
Please modify the existing measure accordingly and provide the updated DAX expression.
DAX Code:
Hey Swami_om ,
upload a PBIX file to OneDrive or Dropbox, that contains sample data but besides represents your semantic model (realtionships, calculated columns, and measures).
Next to that describe the expected outcome based on the sample data you provided.
Regards,
TomWelcome to the forums.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523Hi Swami_om,
Hope you're doing well!
I agree with lbendlin and TomMartens.
Can you confirm that you want an output loke this ?
New York (5) | Chicago (2) | Austin (1)
If yes, here's a proposition to test it that can maybe helps you :
Visited Cities (Final v2) =
VAR EmployeeEmail =
SELECTEDVALUE('WorkdayBridge'[Email])VAR OfficeCity =
SELECTEDVALUE('WorkdayBridge'[Office City])VAR SelectedLocation =
SELECTEDVALUE('WorkdayBridge'[Location])/* Ensure employee is part of selected location */
VAR IsEmployeeInLocation =
CALCULATE(
COUNTROWS('WorkdayBridge'),
REMOVEFILTERS(NetworkData),
'WorkdayBridge'[Email] = EmployeeEmail,
'WorkdayBridge'[Location] = SelectedLocation
)/* Check if employee has at least one visit to Office City */
VAR HasOfficeVisit =
CALCULATE(
COUNTROWS(NetworkData),
REMOVEFILTERS(NetworkData),
NetworkData[UserEmail] = EmployeeEmail,
NetworkData[SP.City] = OfficeCity
)/* Build Office City string with visit count */
VAR OfficeCityWithCount =
OfficeCity & " (" & HasOfficeVisit & ")"/* Get other visited cities with visit counts */
VAR OtherCities =
CALCULATE(
CONCATENATEX(
ADDCOLUMNS(
DISTINCT(NetworkData[SP.City]),
"@VisitCount",
CALCULATE(
COUNTROWS(NetworkData),
ALLEXCEPT(NetworkData, NetworkData[SP.City])
)
),
NetworkData[SP.City] & " (" & [@VisitCount] & ")",
" | ",
NetworkData[SP.City],
ASC
),
REMOVEFILTERS(NetworkData),
NetworkData[UserEmail] = EmployeeEmail,
NetworkData[SP.City] <> OfficeCity
)RETURN
IF(
NOT ISBLANK(EmployeeEmail)
&& NOT ISBLANK(OfficeCity)
&& IsEmployeeInLocation > 0,IF(
HasOfficeVisit > 0,
IF(
ISBLANK(OtherCities),
OfficeCityWithCount,
OfficeCityWithCount & " | " & OtherCities
),
""
),
BLANK()
)
6 Replies
- lbendlin
Super User
Welcome to the forums.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523 - oussamahaimoud
Memorable Member
Hi Swami_om,
Hope you're doing well!
I agree with lbendlin and TomMartens.
Can you confirm that you want an output loke this ?
New York (5) | Chicago (2) | Austin (1)
If yes, here's a proposition to test it that can maybe helps you :
Visited Cities (Final v2) =
VAR EmployeeEmail =
SELECTEDVALUE('WorkdayBridge'[Email])VAR OfficeCity =
SELECTEDVALUE('WorkdayBridge'[Office City])VAR SelectedLocation =
SELECTEDVALUE('WorkdayBridge'[Location])/* Ensure employee is part of selected location */
VAR IsEmployeeInLocation =
CALCULATE(
COUNTROWS('WorkdayBridge'),
REMOVEFILTERS(NetworkData),
'WorkdayBridge'[Email] = EmployeeEmail,
'WorkdayBridge'[Location] = SelectedLocation
)/* Check if employee has at least one visit to Office City */
VAR HasOfficeVisit =
CALCULATE(
COUNTROWS(NetworkData),
REMOVEFILTERS(NetworkData),
NetworkData[UserEmail] = EmployeeEmail,
NetworkData[SP.City] = OfficeCity
)/* Build Office City string with visit count */
VAR OfficeCityWithCount =
OfficeCity & " (" & HasOfficeVisit & ")"/* Get other visited cities with visit counts */
VAR OtherCities =
CALCULATE(
CONCATENATEX(
ADDCOLUMNS(
DISTINCT(NetworkData[SP.City]),
"@VisitCount",
CALCULATE(
COUNTROWS(NetworkData),
ALLEXCEPT(NetworkData, NetworkData[SP.City])
)
),
NetworkData[SP.City] & " (" & [@VisitCount] & ")",
" | ",
NetworkData[SP.City],
ASC
),
REMOVEFILTERS(NetworkData),
NetworkData[UserEmail] = EmployeeEmail,
NetworkData[SP.City] <> OfficeCity
)RETURN
IF(
NOT ISBLANK(EmployeeEmail)
&& NOT ISBLANK(OfficeCity)
&& IsEmployeeInLocation > 0,IF(
HasOfficeVisit > 0,
IF(
ISBLANK(OtherCities),
OfficeCityWithCount,
OfficeCityWithCount & " | " & OtherCities
),
""
),
BLANK()
)- Swami_omRegular Visitor
This helped me a lot
- TomMartens
Super User
Hey Swami_om ,
upload a PBIX file to OneDrive or Dropbox, that contains sample data but besides represents your semantic model (realtionships, calculated columns, and measures).
Next to that describe the expected outcome based on the sample data you provided.
Regards,
Tom - v-saisrao-msft
Community Support
Hi Swami_om,
Have you had a chance to review the solution we shared by TomMartens oussamahaimoud ? If the issue persists, feel free to reply so we can help further.
Thank you. - v-saisrao-msft
Community Support
Hi Swami_om,
Checking in to see if your issue has been resolved. let us know if you still need any assistance.
Thank you.