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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Grouping column

Hi! I need to create a formula, when I will use an existing table but with grouping, how can I do it?

1 ACCEPTED SOLUTION

@Anonymous 

Please try this

Total Scores =
SUMX (
    DISTINCT (
        SELECTCOLUMNS (
            CALCULATETABLE ( Table, ALLEXCEPT ( Table, Table[question] ) ),
            "@question", [question],
            "@score", [score]
        )
    ),
    [@score]
)

View solution in original post

15 REPLIES 15
tamerj1
Super User
Super User

Hi @Anonymous 

this is a very general question. Would you please provide more details about your data structure and the expected results. 

@Anonymous 

By group you mean same question same score? How many groups there are for each question? Are trying to sum the distinct values of scores of the question groups?

Anonymous
Not applicable

Yes, I don't need to sum 3 times 0.21, it will be 0.63, but I need only 0.21. This score is question score, not persons, but it is shown per person, that's the problem

 

@Anonymous 

Please try this

Total Scores =
SUMX (
    DISTINCT (
        SELECTCOLUMNS (
            CALCULATETABLE ( Table, ALLEXCEPT ( Table, Table[question] ) ),
            "@question", [question],
            "@score", [score]
        )
    ),
    [@score]
)
Anonymous
Not applicable

It's very good solution, but, what if instead of sum, I need average, when I just put averagex, it works wrongly

 

@Anonymous 

Yes exactly

Anonymous
Not applicable

but it doesn't work, when I just put averagex

 

@Anonymous 
I don't know how your visual look like but you may try

 

Average Scores =
AVERAGEX (
    DISTINCT (
        SELECTCOLUMNS (
            CALCULATETABLE ( ALL ( Table ), ALLEXCEPT ( Table, Table[question] ) ),
            "@question", [question],
            "@score", [score]
        )
    ),
    [@score]
)

 

Anonymous
Not applicable

ALL() takes a column, not a table

It take either. But please re- copy the code as the location of all was wrong 

Can you explain further with example? Also please confirm you are creating a calculated column not a measure

Anonymous
Not applicable

I'm creating a measure, sorry that I haven't mentioned. For sum it worked, for average not

Anonymous
Not applicable

It works for now, I need to do it couple times for some cases, but thanks a lot!!!

Anonymous
Not applicable

Cognitive ease = SUMX(Filter(table , table[question] = "first_question"), table[score])

That is my formula, I need to some how add grouping that I need

Anonymous
Not applicable

Remember, couple days ago I asked about this: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Creating-a-column-count-by-different-values-f...
So, as example, now I created a column "score":

person_idquestionscore
1(first question)0.21
2(first question)0.21
3(first question)0.21
1(second question)0.83
2(second question)0.83
3(second question)0.83
4(first question)0.35
5(first question)0.35
6(firstquestion)0.35

 

So, now I need to make a formula, that will sum up the score, per question, but, as I used COUNTROWS ( CALCULATETABLE ( Table, ALLEXCEPT ( Table, Table[Column1] ) ) ) to show the score, it shows the same one score per each person, but I don't need sum all 6 score per first question, I want to sum 0.21 + 0.35. Hope you got the problem, if not, I'll try to explain in a diff way.

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.