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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AllysonV
Regular Visitor

Need a measure or formula that will sum a measure based on multiple columns.

I am a newby to Power BI and am trying to create a measure that sums a measure 'FACT-Accounting'[Total Expense] based on columns named 'FACT-Accounting'[GLACT] and 'FACT-Accounting'[Month Name].   I found a formula on line that looked as though it would work: 

 
1 Total Monthly Expense by GL Code = 
2 GROUPBY('FACT-Accounting','FACT-Accounting'[GLACNT],'FACT-Accounting'[Month Name],
3 "Total Monthly Expense",  SUMX(CURRENTGROUP(),'FACT-Accounting'[Total Expense]))
However, I get the error message "The CALCULATE function cannot be used in an expression
argument for the GROUPBY() FUNCTION"
 
Any ideas on how to troubleshoot this error would be much appreciated. Or alternative
means to acheive the same result.
 
2 REPLIES 2
Anonymous
Not applicable

My suggestion would be to first try to learn the bare minimum about Power BI and DAX to understand the basic concepts and only then start working with this. There are many great resources around the Internet. Just a question of reaching out. You can start with YouTube.

 

GROUPBY is a very, very, very, bad choice and signalizes you're just trying to do Power BI in a careless, unthoughtful, monkey fashion. THIS WILL NOT WORK, I'm afraid. It's like giving a monkey a razor... You can do more harm to others and yourself than you can imagine. No, sorry to say that but it's actually TRUE.

 

Best

Darek

Stachu
Community Champion
Community Champion

if you want the 'FACT-Accounting'[GLACT] and 'FACT-Accounting'[Month Name] in the rows of the table visual then simple SUM will be enough (it will calculate it based on the filter context of the columns you put in the visual)

Expense = SUM('FACT-Accounting'[Total Expense])

So basically:

1) create the Expense measure

2) drag 'FACT-Accounting'[GLACT] to the visual

3) change the visual to table

4) drag 'FACT-Accounting'[Month Name] to the same visual

5) drag the measure from 1) to the same visual



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors