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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Want to sum a column based on the value of another column in that same table

aherna12_0-1689877232979.png

I have this table, labeled 'BILLINGMATERIALITEM', and I want to sum the 'Total' column only if the 'BillingItemTypeID' column is equal to 33. I tried to do a new measure with the formula if(column = 33, then sum column'Total') but I got an error that said I have to many values that are 33 in the BillingItemTypeID column. There are other values in that column, but all I need is the sum for value 33 and put it in a table on Power BI

 

aherna12_1-1689877614842.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Total Supplemental = calculate(sum('BILLINGMATERIALITEM'[Total]),filter('BILLINGMATERIALITEM',('BILLINGMATERIALITEM'[BillingItemTypeId])=33))

 

Changing it to this got it work. Thank you!

View solution in original post

3 REPLIES 3
rubayatyasmin
Super User
Super User

with if you need to add agg func with your expression. try this instead

 

TotalForBillingItem33 = 
CALCULATE(
    SUM('BILLINGMATERIALITEM'[Total]),
    FILTER(
        ALL('BILLINGMATERIALITEM'),
        'BILLINGMATERIALITEM'[BillingItemTypeID] = 33
    )
)

 

rubayatyasmin_0-1689517080227.png


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Anonymous
Not applicable

Yes, this definetly helped! however, I have it in a table where it is getting sorted by the 'Billing ID' column. When I put it in that tabel it just shows me the total sum. Is there any way you can get it so it sorts by the 'Billing ID' column? Thanks!

 

aherna12_0-1689881072242.png

 

Anonymous
Not applicable

Total Supplemental = calculate(sum('BILLINGMATERIALITEM'[Total]),filter('BILLINGMATERIALITEM',('BILLINGMATERIALITEM'[BillingItemTypeId])=33))

 

Changing it to this got it work. Thank you!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors