Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello, I'm really new and inexperienced with DAX and PowerBI
I'm trying to Sum/Count a certain field in the row level, but my Sum/Count only displays the total of everything, repeating for every row of my Table, i.e:
TABLE 01 = "LIKES"
ID_POST | ID_LIKE | ID_USER |
1523 | 1000 | 0001 |
1523 | 1023 | 0002 |
1222 | 1923 | 0001 |
1222 | 2311 | 0003 |
1523 | 4223 | 0004 |
TABLE 02 = "POSTS"
POST_DATE | POST_ID | POST_CONTENT |
07/10/2022 | 1523 | This is a example post... |
08/10/2022 | 1222 | Example Post number 2... |
TABLE 03 = "USERS" -> EXPECTED RESULT
USER_ID | USER_NAME | COUNT/SUM_LIKES |
01 | NAME01 | 2 |
02 | NAME02 | 1 |
03 | NAME03 | 1 |
04 | NAME04 | 1 |
What I'm getting ->
USER_ID | USER_NAME | COUNT/SUM_LIKES |
01 | NAME01 | 5 |
02 | NAME02 | 5 |
03 | NAME03 | 5 |
04 | NAME04 | 5 |
I don't now how to make the sum per user, the only thing I get is the total of everything..
Can anyone give me a hand?
Solved! Go to Solution.
You likely didn't wire your data model. Should look something like this (although this is questionable as posts have to be done by users too, no?)
Hi @Aldimar_Junior ,
According to your description, I reproduce your problem.
When the two tables don't have relationship, if you select count the column, it will count all the rows, it's correct. If you select summarize, you will find the visual broken.
But your USER_ID (eg 01) in USERS table and ID_USER(eg 0001) in LIKES table are not in the same format, after create relationship, it still can't recognize.
Here's my solution. Don't make relationship and create a measure.
Count =
COUNTROWS (
FILTER (
'LIKES',
CONTAINSSTRING ( 'LIKES'[ID_USER], MAX ( 'USERS'[USER_ID] ) )
)
)
Get the result.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You likely didn't wire your data model. Should look something like this (although this is questionable as posts have to be done by users too, no?)
It was indeed a relationship problem, thanks for that!!
User | Count |
---|---|
77 | |
74 | |
42 | |
32 | |
28 |
User | Count |
---|---|
100 | |
93 | |
52 | |
50 | |
48 |