Forum Discussion
Matrix Totals Incorrect
- 9 months ago
Hi ls784,
Please try this
CallCount =
VAR UniqueUsers =
SUMMARIZE(
UserGroups,
UserGroups[User] -- distinct list of users in current visual context
)
RETURN
SUMX(
UniqueUsers,
VAR CurrentUser = UserGroups[User]
VAR UserCallCount =
CALCULATE(
DISTINCTCOUNT(Calls[CallID]),
FILTER(Calls, Calls[User] = CurrentUser)
)
VAR GroupCount =
CALCULATE(
DISTINCTCOUNT(UserGroups[SubGroup]),
FILTER(UserGroups, UserGroups[User] = CurrentUser)
)
RETURN DIVIDE(UserCallCount, GroupCount, 0)
)if it doesn't work, please share sample data
Hi ls784,
Try below DAX
CallCount =
VAR UsersTable =
VALUES(UserGroups[User])
RETURN
SUMX(
UsersTable,
VAR UserCallCount =
CALCULATE(DISTINCTCOUNT(Calls[CallID]), Calls[User] = UserGroups[User])
VAR GroupCount =
CALCULATE(DISTINCTCOUNT(UserGroups[SubGroup]), UserGroups[User] = UserGroups[User])
RETURN DIVIDE(UserCallCount, GroupCount, 0)
)
π I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
π‘ Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
π As a proud SuperUser and Microsoft Partner, weβre here to empower your data journey and the Power BI Community at large.
π Curious to explore more? [Discover here].
Letβs keep building smarter solutions together!
- ls7849 months agoHelper I
Thank you for your help.
Unfortunately I got an error with this code:- grazitti_sapna9 months agoSuper User
Ok, got it ls784
Try this
CallCount =
VAR UsersTable = VALUES(UserGroups[User])
RETURN
SUMX(
UsersTable,
VAR CurrentUser = [User] -- store current user in variable
VAR UserCallCount =
CALCULATE(
DISTINCTCOUNT(Calls[CallID]),
FILTER(Calls, Calls[User] = CurrentUser)
)
VAR GroupCount =
CALCULATE(
DISTINCTCOUNT(UserGroups[SubGroup]),
FILTER(UserGroups, UserGroups[User] = CurrentUser)
)
RETURN DIVIDE(UserCallCount, GroupCount, 0)
)- ls7849 months agoHelper I
Unfortunately this doesn't quite give me what I want, the totals don't add up because we can see it's counting the duplicates