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

Dax measure: SUM exclude rows based on combination of 2 columns

Hi Al

 

I want to create a sum formula but exclude certain rows. The data is a large fact table of milions of records so I do not want to create a new column for this summation. 

Namedateamount
John31-12-202020
John1-1-202050
sue1-2-202030

 

I want to have a sum of all values exept where Name is John and the date is after 31-12-2020. So I want to exclude John from the calculation for all rows with date after 31-12-2020

Desired result in above example = 50. 

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @BobKoenen ,

 

If I get your requirements well, you can use the following measure:

 

Measure = CALCULATE(SUM('Table'[amount]),FILTER('Table','Table'[Name]<>"John" && 'Table'[date]>=DATE(2020,12,31)))+ CALCULATE(SUM('Table'[amount]),'Table'[date]<DATE(2020,12,31))

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

3 REPLIES 3
v-deddai1-msft
Community Support
Community Support

Hi @BobKoenen ,

 

If I get your requirements well, you can use the following measure:

 

Measure = CALCULATE(SUM('Table'[amount]),FILTER('Table','Table'[Name]<>"John" && 'Table'[date]>=DATE(2020,12,31)))+ CALCULATE(SUM('Table'[amount]),'Table'[date]<DATE(2020,12,31))

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

jaideepnema
Solution Sage
Solution Sage

@BobKoenen 

You can use a measure like this :

Amount Measure = CALCULATE(SUM('Table'[amount]),FILTER('Table','Table'[Name]="John" && 'Table'[date]>DATE(2019,12,31)))

Please accept this as a solution if your question has been answered !!

Appreciate a Kudos 😀

Hi Unfortunatly this does not work 

I want to exclude all amounts for John after 31-12-2020. So I adopted the formula

Measure = CALCULATE(SUM(table[amount], FILTER(table, table[name] <> "John" && Table[Date]>DATE(2019,12,31)). 

But this exlcudes ALL rows before the date, not only the rows of JoHN

 

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.