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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
acs
Regular Visitor

A conditional MAX?

Hello - have been learning a lot by reading these forums and all the helpful posts on here. Now I've run up against a problem I cannot find the answer for and hoping someone can help.

 

I have data listing a number of products we offer. The columns are:

 

1. Product name (e.g. Red BMX, Blue BMX, Green Racer etc.)

2. Version number (v1, v2, v3 etc.)

3. Product Type (e.g. BMX, Racer, Chopper etc.)

4. Month

5. Number of Sales

 

Something like this:

 

ProjectVersionTypeMonthSales
Red BMX1BMXJan 201753
Blue BMX1BMXJan 201721
Green Racer1RacerJan 2017981
Red BMX1BMXFeb 201798
Red BMX2BMXFeb 2017103

 

The issue I have is when I set-up any charts to total sales by type it shows (as the function should) the total sales for all BMXs together. So for the above a MAX gives me 103 (the highest sales figure for anything with type=BMX)

 

However, I want sales of v2 of the Red BMX to be added to the sales of v1 - however a SUM function doesn't work for me either, as the monthly figures we get are already totalised so include previous months' sales.

 

I want to be able to see (and show in charts):

a) how many BMXs have we sold regardless of version or colour

b) how many Red BMXs (and how many Blue etc.)

c) how many Red BMXs by version number

 

Is there a way to do this that I am missing - that is scalable and repeatable (as we add further versions, colours etc.?).

 

Thanks in advance.

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft Employee
Microsoft Employee

@acs,

 

Could you give us a expected chart as the sample? To get the vaule you want, we can use ALLEXPECT function.
TypeTotal = CALCULATE(SUM(Table1[Sales]),ALLEXCEPT(Table1,Table1[Type]))
ProjectTotal = CALCULATE(SUM(Table1[Sales]),ALLEXCEPT(Table1,Table1[Type],Table1[Project]))
VersionTotal = CALCULATE(SUM(Table1[Sales]),ALLEXCEPT(Table1,Table1[Type],Table1[Project],Table1[Version]))

Capture.PNG

 

Regards,

Charlie Liao

View solution in original post

4 REPLIES 4
v-caliao-msft
Microsoft Employee
Microsoft Employee

@acs,

 

Could you give us a expected chart as the sample? To get the vaule you want, we can use ALLEXPECT function.
TypeTotal = CALCULATE(SUM(Table1[Sales]),ALLEXCEPT(Table1,Table1[Type]))
ProjectTotal = CALCULATE(SUM(Table1[Sales]),ALLEXCEPT(Table1,Table1[Type],Table1[Project]))
VersionTotal = CALCULATE(SUM(Table1[Sales]),ALLEXCEPT(Table1,Table1[Type],Table1[Project],Table1[Version]))

Capture.PNG

 

Regards,

Charlie Liao

Greg_Deckler
Community Champion
Community Champion

I may not totally understand what you are going for, but if I understand correctly, couldn't you do something like:

 

TotalSales = CALCULATE(SUM([Sales]),FILTER(BMX,[Month]=MAX([Month])))


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

My suggestion would be to normalize your source data, either at the real source or in Power Query:

  1. Put the colour in a separate column.
  2. De-accumulate Sales figures.

In your example: would the 103 Version 2 Sales include the 98 Version 1 Sales?

 

Does accumulation start each year in January?

 

What is your format for Month: text or a date (e.g. first of the month)? This require to de-accumulate the Sales correctly.

Specializing in Power Query Formula Language (M)

 Appreciate the swift replies. Going to try and work my way through both suggestions and see if I can get either to work.

 

Meanwhile, if it helps:

 

"In your example: would the 103 Version 2 Sales include the 98 Version 1 Sales?"

No.

 

"Does accumulation start each year in January?"

Yes (well, not January but at the beginning of our financial year, which is August - so totals run up to 31st July, then reset).

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors