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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
shairado
Frequent Visitor

Get Sales Value from Table dependent on Max Date and multiple ID

Hi,

I am trying to use DAX to get the Sales value from a table, where I have multiple Sales line per ID, each one might have the same date, different date, or no date.

I am trying to only read the Sales values once per ID, where the Date is Max(Date).

 

This is the original table:

Table_1.PNG

 

 

 

 

 

And this is the result I am trying to achieve:

Table_2.PNG

 

 

 

I was able to use DAX to get the Maxdate (latest date) per ID:

Max Date =

CALCULATE(

MAX(‘Table’[Date]),

FILTER(‘Table’[Date]), EARLIER(‘Table’[ID]) = ‘Table’[ID])

)

 

Than, I tried using SUMX, with 2-filter criteria, but the formula below is giving an error:

Unique Sale =

CALCUALTE(

SUMX(‘Table’, ‘Table’[Sales]),

‘Table’[Date] = ‘Table’[Max Date]

&& ‘Table’[ID] = ‘Table’[ID]

)

 

Thanks for your time.

1 ACCEPTED SOLUTION

In case you have date table, you can get cumulative value like this. But in this case it might not work. But try out

 

Cumm Sales = CALCULATE([Sales],filter(date,date[date] <=maxx(date,date[date])))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

Try

Measure = 
VAR __id = MAX ( 'Table'[ID] )
VAR __date = CALCULATE ( MAX( 'Table'[Date] ), ALLSELECTED ( 'Table' ),  'Table'[ID] = __id ) 
RETURN CALCULATE ( sum ( 'Table'[sales] ), VALUES ( 'Table'[ID] ), 'Table'[id] = __id, 'Table'[date] = __date )

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  thanks, this measure works, I was hoping to use a Column (not a measure)

 

The second part, is creating a cummulative Visual, like with a table below:  

Table_3.PNG

 

 

Not sure how to create accumulative DAX using EARLIER and a Measure.

In case you have date table, you can get cumulative value like this. But in this case it might not work. But try out

 

Cumm Sales = CALCULATE([Sales],filter(date,date[date] <=maxx(date,date[date])))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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