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
Anonymous
Not applicable

Calculate with multiple selections in same column

Why do I have 10 books on DAX formulas and Power BI and still can't find the answer to this easy problem?

 

I need this formula rewrote so it will work:

Intercompany Sales = CALCULATE(sum(Sales[Sales]),Sales[CustID]='10275' or '11969' or '12875' or '50013'

 

I need the total sales of all four of these CustID

 

I know I will be ashamed when I see the answer.  Thanks for your help.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Intercompany Sales = CALCULATE(sum(Sales[Sales]),Sales[Sales]=10275 || Sales[Sales]=11969 || Sales[Sales]=12875 || Sales[Sales]=50013)

This assumes numeric data in Sales. If Text, enclose in "".


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Intercompany Sales = CALCULATE(sum(Sales[Sales]),Sales[Sales]=10275 || Sales[Sales]=11969 || Sales[Sales]=12875 || Sales[Sales]=50013)

This assumes numeric data in Sales. If Text, enclose in "".


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thank you so much @Greg_Deckler for answering this, and thank you for asking this question @Anonymous - great community, and this is extremely helpful.

Anonymous
Not applicable

This works perfectly.  I want to personally thank you for all you do on this board helping people like myself be more productive with our time.

Hi smoupre,

 

how would the formula look like if I wanted to filter for ranges? So Sales[Sales]>= 10275 and < 11969?

 

Thanks!

Right, so the filter clause can get complex quickly. So I believe something like this would work:

 

Intercompany Sales = CALCULATE(sum(Sales[Sales]),(Sales[Sales]>=10275 && Sales[Sales]<=11969) || Sales[Sales]=12875 || Sales[Sales]=50013)

 

So, that should be to include sales that are >= 10275 and <=11969 or exactly 12875 or exactly 50013


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hello @Greg_Deckler

 

I have the same issue, but I want to make it dynamic. For example, I have a slicer with 5 types of products and two measure:

 

SelectedProduct = FIRSTNONBLANK(Table[Product], Table[Product])
NumberProducts = CALCULATE(COUNTROWS(Table), FILTER(Table, Product=SelectedProduct))

What I want is the SelectedProduct to give me all(multiple) of the selected values from the slicer and calculate the NumberProducts for all of the selected. Please help me.

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.