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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
DaxBoi
New Member

Conditional SUM

I have a dataset that looks like the following. 

For each ID there is an Attribute which has a score. There is also a target 0-4 with a weighting.

 

I'm looking to create a visual with a differential view of the weighted target score and actual score.

 

My plan is to have columns to calculate these values, however I'm struggling to formulate the DAX for the columns after the ~ symbol. 

I've tried Calculate/SUMX/Filters but can't get these to work as expected. Any help is much appreciated

 

IDAttributeScoreTargetWeighting~Sum(Target*Weight)Diff
1A1400.2~2.6+1.4
1A1410.2~2.6+1.4
1A1420~2.6+1.4
1A1430~2.6+1.4
1A1440.6~2.6+1.4
1A2.........~......
5 REPLIES 5
Anonymous
Not applicable

Hi @DaxBoi 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your data model and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,

Rico Zhou

Greg_Deckler
Community Champion
Community Champion

@DaxBoi  - You said:

"For clarity, I'm looking to sum based on a number of attributes - such as ID, and Attribute. And then do a second calculation (finding the differential) based on the same attributes"

 

PBIX is attached under sig, Table (4)

 

So, 2 columns:

Sum Target Weight = 
    VAR __Table = 
        ADDCOLUMNS(
            FILTER('Table (4)',[ID]=EARLIER([ID]) && [Attribute]=EARLIER([Attribute])),
            "Product",[Target]*[Weighting]
        )
RETURN
    SUMX(__Table,[Product])


Diff = 
    VAR __Table = 
        ADDCOLUMNS(
            FILTER('Table (4)',[ID]=EARLIER([ID]) && [Attribute]=EARLIER([Attribute])),
            "Product",[Score]*[Weighting]
        )
RETURN
    SUMX(__Table,[Product]) - [Column]

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@DaxBoi , As measures

 

new score = sumx(All(Table),[Target]*[Weighting])

or
new score = sumx(Allselected(Table),[Target]*[Weighting])
or
new score = calculate(sumx(Table,[Target]*[Weighting]),All(Table))

or

new score = calculate(sumx(Table,[Target]*[Weighting]),Allselected(Table))

diff = Sum(Table[Score]) -[new score]

 

As new column

new score = sumx(Table,[Target]*[Weighting]

diff = [Score] -[new score] //Both are column here

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I think I wasn't clear in my question

 

The aim is to have a conditional sum that looks like this. The sum would be over the 5 total rows for


ID = 1 Attribute = A1

 

and then another sum over the rows for

 

ID = 1 Attribute = A2

 

and so on.

 

IDAttributeScoreTargetSum(T*W)Diff
1A14(0-4)2.6+1.4
+4rows asabove   
1A23(0-4)3.5-0.5
+4rows    
1A34(0-4)1+3.0
DaxBoi
New Member

For clarity, I'm looking to sum based on a number of attributes - such as ID, and Attribute. And then do a second calculation (finding the differential) based on the same attributes 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.