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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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())

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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