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
Reawaken
Regular Visitor

Add up values in one column based on whether a value in another column is of a specific value

Hi there,

 

I am trying to add up values in a column based on whether a value in another column has a value of 4 or 5.

Reawaken_0-1674257515520.png

 

What I'd like to be able to do, from the information in the pictur above, is scan through the NEW CRATE column, and if the value is a "4" or "5", I want to add that value from the BALANCE column and place it in a new variable or that I can use in a division equation.

 

I'd like to see the value of "21400" stored in a new value and then later used for downstream DAX functions.  What I have so far is this:

CALCULATE(
    VALUE(ALL(Equifax[New Crate], Equifax[New Crate] = MAX(Equifax[New Crate] = 4 OR 5)))
)
 
I'm learning DAX for work and need some help with this; not as straight forward as python code, for e.g.
 
Thanks!

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Write this measure and drag it to a card visual

Measure = calculate(sum(Data[Balance]),data[new crate]=4||data[new crate]=5)

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Write this measure and drag it to a card visual

Measure = calculate(sum(Data[Balance]),data[new crate]=4||data[new crate]=5)

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

 

Can you help me understand the "||" and how this is used properly?  I cant seem to finish the rest of your DAX expression cause I'm getting an error message, "The following syntax error occurred during parsing: Invalid toekn, Line 1, Offset 52, |E".  The "E" is the first letter of the table of data I'm using.  Might be good to mention that both "Balance" and "New Crate" are in the same table.

 

Thanks for your help, Ashish!

You are welcome.  || means OR.  Write my formula as a measure.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@Reawaken , In case you need a new column

 

New column = if( Equifax[New Crate] in {4,5} , [Balance], blank())

 

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

Hi Amit,

 

You're right that my table is called Equifax, with dimenions Balance, New Crate, etc., but I dont think your expression is working cause I don't see the drop down to select "Equifax[New Crate]" after the "IF" statement.  Help!  I'm a newbie at this haha.

 

Thanks!

 

Paul

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.