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

Adding a column with the required logic

Hi All, I was hoping someone could help with this.

 

I have the following table:

 

ClassificationCompanyValue(column needed)
EApple1060
ETesla1555
EApple5060
ETesla4055
SApple2030
SApple1030
STesla55

 

Basically I nede a column that does the sum of the value for each classification and company and repeats these values in the cells wherever the company name comes up.

 

For example Apple has to E's, valued 10 and 50. so I want my column to say 60 for both these fields.

 

Tried to use a mix of calculate, sum, and allexcept but not working. Please can someone help?

 

@amitchandak 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

please try

Column = CALCULATE(sum(Table1[Value]),ALLEXCEPT(Table1,Table1[Classification],Table1[Company]))

1.PNG 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , I think you can add a calculated column like this

Calculated Column = SUMX (
    FILTER (
        ALL ( DS ),
        DS[Company] = EARLIER ( DS[Company] )
            && DS[Classification] = EARLIER ( DS[Classification] )
    ),
    DS[Value]
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

ryan_mayu
Super User
Super User

@Anonymous 

please try

Column = CALCULATE(sum(Table1[Value]),ALLEXCEPT(Table1,Table1[Classification],Table1[Company]))

1.PNG 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

any idea how I can do this in powerquery so I can unpivot the data?

Anonymous
Not applicable

Thanks for this! works well. How can I amend it so that the score is averaged? i.e. because Apple has 2 'E' entries, I want to divide the answer from your code by this?

@Anonymous 

you can try this

Column = CALCULATE(sum(Table1[Value]),ALLEXCEPT(Table1,Table1[Classification],Table1[Company]))/CALCULATE(COUNTROWS(Table1),ALLEXCEPT(Table1,Table1[Classification],Table1[Company]))

why do you want to unpivot table? what's the output that you want?

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.