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
michaelshparber
Advocate V
Advocate V

Nested SQL in a Measure

Hello friends,

I need to calculate monthly sales amount for each customer ONLY IF the customer has a sales transaction of $500 and above.

If there is such a transaction, then I need to summ ALL of that customer's sales in that month.

It's like first selecting customers/month that have this transactions

and then selecting from the sales table joining with the previous results.

I was able to solve it using a calculated column and a measure.

But I am looking for an elegant all-in-one measure solution.

Thank you

Michael

1 ACCEPTED SOLUTION
jthomson
Solution Sage
Solution Sage

So if we have this data:

 

test440.PNG

 

We'd want bob to be 1500 and dave to be 2000 as they have individual line(s) of at least 500, but jim would be 0 as he doesn't? In that case, this works for me:

 

if(max('Table'[salevalue])>=500,sum('Table'[salevalue]),blank())

View solution in original post

2 REPLIES 2
jthomson
Solution Sage
Solution Sage

So if we have this data:

 

test440.PNG

 

We'd want bob to be 1500 and dave to be 2000 as they have individual line(s) of at least 500, but jim would be 0 as he doesn't? In that case, this works for me:

 

if(max('Table'[salevalue])>=500,sum('Table'[salevalue]),blank())

@jthomson 

I think the solution can't be more simple than yours!

Thank you!

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.