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
swebb
Helper II
Helper II

Need help with query for adding totals

All,

 

I have a finance report I'm working on looking for total values that roll up in to each other (E.g., Total Revenue - Total Expenses = Net Operating Income) , problem is I have it all in one table because of the way the end user wants it structured in the matrix layout. I think that a custom column will work best here, for the needs of the user. Here's what I have, but it is throwing errors:

if [accountNumber] >= 410000 and [accountNumber] <= 450000 then [Converted Totals]
else if [accountNumber] > 450000 then [Converted Totals]
else null

 

The account number column corresponds to the type ("Expense", "Revenue", etc.) my issue is I don't know how to sum each column value that corresponds to 410000, 420000, 430000, 440000, and 450000 --- I hope this makes sense. Let me know if not and I'll do my best to clarify.

3 REPLIES 3
jennratten
Super User
Super User

Hello - your logic works for me.  In order for this to work as is, your accountNumber and Converted Totals columns must be numeric data types and must not contain text.  What kind of error are you getting?  Can you post a snip of your data?

 

jennratten_0-1679940615975.png

 

If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.

Proud to be a Microsoft Fabric Super User

@jennratten Thanks for pointing out the obvious, lol, my data types were wrong! Follow up question, I need to do mathematical operations against these numbers. Example, for everything identified as being between 410000 and 450000, add those corresponding values and put them in the new column, additionally, anything greater than 450000 needs to be added as a different value, but in the same new column. Does that make sense? 

No worries.  🙂  Yes, this makes sense, but can you please post an example of what you would like the resulting table to look like?  I would like to make sure we are on the same page about what you are trying to do.  For example, if you add up everything in the column that is between 410000 and 450000 and then add it as a new column, you will have duplicate values in rows.  Is that what is expected?

If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.

Proud to be a Microsoft Fabric Super User

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.