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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
amby0430
Regular Visitor

Show Total first occurance only Power BI table visual

I am trying to come up with a formula that will visually show only the total of one row on the first occurance in a table. I know this can be done in a matrix, but I need it to be a table. Below is my table which I am summing Sales for an Account. I have multiple Contracts with differing sales values, however I want the total sales (Sum Sales) to only show up in the first occurance of the contract start date and the subsequent fields for each additional contract start to be null.  Can this be achieved?

 

Thank you!

 

AccountContractSalesContract StartSum Sales
Account AContract A1003/6/20251000
Account BContract B2003/7/2025200
Account CContract C3003/8/2025300
Account AContract B4003/9/2025 
Account AContract C5003/10/2025 
1 ACCEPTED SOLUTION

@amby0430 I thought you wanted it by Account and Contract ID. If you only want it by Account:

Sum Sales Measure = 
  VAR __Account = MAX( 'Table'[Account] )
  VAR __Date = MAX( 'Table'[Contract Start] )
  VAR __Table = FILTER( ALL( 'Table' ), [Account] = __Account )
  VAR __MinDate = MINX( __Table, [Contract Start] )
  VAR __Result = IF( __Date = __MinDate, SUMX( __Table, [Sales] ), BLANK() )
RETURN
  __Result

It is generally helpful if you explain why something didn't work versus "did not work" as the latter isn't exactly helpful in determining what is wrong with the proposed solution. Just FYI.



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@amby0430 Try:

Sum Sales Measure =
  VAR __Account = MAX( 'Table'[Account] )
  VAR __Contract = MAX( 'Table'[Contract] )
  VAR __Date = MAX( 'Table'[Contract Start] )
  VAR __Table = FILTER( ALL( 'Table' ), [Account] = __Account && [Contract] = __Contract )
  VAR __MinDate = MINX( __Table, [Contract Start] )
  VAR __Result = IF( __Date = __MinDate, SUMX( __Table, [Sales] ), BLANK() )
RETURN
  __Result


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Unfortunately it did not work. Updating based on your comments. My apologies, I am just beginning to use the forum more in my work. I will take this into the account in the future, however with the above the result was 

AccountContractContract StartSum of SalesSum Sales Measure
Account AContract A3/6/2025 0:00100100
Account AContract B3/9/2025 0:00400400
Account AContract C3/10/2025 0:00500500
Account BContract B3/7/2025 0:00200200
Account CContract C3/8/2025 0:00300300

 

@amby0430 I thought you wanted it by Account and Contract ID. If you only want it by Account:

Sum Sales Measure = 
  VAR __Account = MAX( 'Table'[Account] )
  VAR __Date = MAX( 'Table'[Contract Start] )
  VAR __Table = FILTER( ALL( 'Table' ), [Account] = __Account )
  VAR __MinDate = MINX( __Table, [Contract Start] )
  VAR __Result = IF( __Date = __MinDate, SUMX( __Table, [Sales] ), BLANK() )
RETURN
  __Result

It is generally helpful if you explain why something didn't work versus "did not work" as the latter isn't exactly helpful in determining what is wrong with the proposed solution. Just FYI.



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

This solution worked. Below is the result. Thank you!

 

AccountContractContract StartSum of SalesSum Sales Measure
Account AContract A3/6/2025 0:001001000
Account AContract B3/9/2025 0:00400 
Account AContract C3/10/2025 0:00500 
Account BContract B3/7/2025 0:00200200
Account CContract C3/8/2025 0:00300300

Helpful resources

Announcements