Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Aldimar_Junior
Frequent Visitor

Sum or Count of a value per row

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_POSTID_LIKEID_USER
152310000001
15231023

0002

12221923

0001

12222311

0003

15234223

0004

 

TABLE 02 = "POSTS"

POST_DATEPOST_IDPOST_CONTENT
07/10/20221523This is a example post...
08/10/20221222Example Post number 2...

 

TABLE 03 = "USERS" -> EXPECTED RESULT

USER_IDUSER_NAMECOUNT/SUM_LIKES
01NAME012
02NAME021
03NAME031
04NAME041

 

What I'm getting ->

USER_IDUSER_NAMECOUNT/SUM_LIKES
01NAME015
02NAME025
03NAME035
04NAME045

 

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?

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

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?)

lbendlin_0-1665279277355.png

 

lbendlin_1-1665279318108.png

 

View solution in original post

3 REPLIES 3
v-yanjiang-msft
Community Support
Community Support

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.

vkalyjmsft_0-1665391012865.png

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.

vkalyjmsft_1-1665391594457.png

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.

lbendlin
Super User
Super User

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?)

lbendlin_0-1665279277355.png

 

lbendlin_1-1665279318108.png

 

It was indeed a relationship problem, thanks for that!!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.