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
Rsanjuan
Helper IV
Helper IV

Add a column to sum sales if a specific criteria is met

There are two colums:

 

Sales and Job Phase

 

Job Phase has the following statuses:  Confirmed, In Process, and In Field.

 

I need to create a column where it adds up the sales only when Job Phase = confirmed or in process.  

 

Can someone please help me what would be the correct syntax to add in the query editor?  Thank you!

 

 

2 ACCEPTED SOLUTIONS

I changed it to this:  

 

ConfirmedInProcess Total = CALCULATE(Sum('SF Project Report'[Sales.amount]),'SF Project Report'[Job Phase]=Confirmed||'SF Project Report'[Job Phase]=In Process)

 

And it says Syntax for "In" is incorrect

 

 

View solution in original post

jahida
Impactful Individual
Impactful Individual

You lost the quotes now on the strings (Confirmed -> "Confirmed", In Process -> "In Process")

View solution in original post

6 REPLIES 6
asocorro
Skilled Sharer
Skilled Sharer

You have several ways of doing this.  First, I got this raw data:

 

raw data.png

 

Then I can get grouping and sum like this:

 

table with sum.png

 

Than I can filter like this:

 

 

 

ft.png

 

And I can also have a measure like this:

 

Sales For Phases 1 and 2 = CALCULATE(SUM(SalesHistory[Sales]), SalesHistory[Phase] = 1 || SalesHistory[Phase] = 2)

 

measure.png

 

 

Connect with me in LinkedIn: https://pr.linkedin.com/in/adolfosocorro
Follow me on Twitter: https://twitter.com/AdolfoSocorro

Thank you for your help.  I tried to set it up like this:

 

ConfirmedInProcess Total = CALCULATE(Sum('SF Project Report'[Sales.amount]),'SF Project Report'[Job Phase]='Confirmed'||'SF Project Report'[Job Phase]='In Process'))

 

but I'm getting a syntax error.  Any ideas?

jahida
Impactful Individual
Impactful Individual

Extra right bracket at the end?

I changed it to this:  

 

ConfirmedInProcess Total = CALCULATE(Sum('SF Project Report'[Sales.amount]),'SF Project Report'[Job Phase]=Confirmed||'SF Project Report'[Job Phase]=In Process)

 

And it says Syntax for "In" is incorrect

 

 

jahida
Impactful Individual
Impactful Individual

You lost the quotes now on the strings (Confirmed -> "Confirmed", In Process -> "In Process")

Got it working.  Thanks!

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.