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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Calculate one distinct date in a measure


Hi all,

I have a scenario where i want to sum the Amounts for customers based on when they did a transaction. I've successfully calulated this using the following measure 
Sum_LastTransactions =

CALCULATE (
SUM('Data'[Amount]),
GENERATE (
VALUES ( 'Data'[CustomerID] ),
LASTDATE ( 'Data'[TransactioDate] )
)
)
However in my data I have duplicate rows (used for other anaysis) such as transaction AC00. Using my measure above the total 
for AC00 is 20 where by i need it to be 10. I have tried using disctinct function but dont seem to arrive to solution.

How can I go about this?

The data is as follows

CustomerIDTransactionDate Amount 
AA111/01/202230
AA111/02/202240
AB011/02/202220
AC001/01/202210
AD011/03/202250
AA112/03/2022100
AB012/03/2022200
AC001/01/202210

 Desired Output AA11 is 100, AB01 200 , AC00 is 10 [Sum_LastTransactions] = 310

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Simple enough

CNENFRNL_0-1648821871156.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

Simple enough

CNENFRNL_0-1648821871156.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

tamerj1
Super User
Super User

Hi @Anonymous 
One way to do that

Sum_LastTransactions1 = 
VAR MaxDate = 
    MAXX ( 
        CALCULATETABLE ( 
            'Data', 
            ALLEXCEPT ( 'Data', 'Data'[CustomerID] )
        ),
    'Data'[TransactionDate]
    )
RETURN
    MAXX ( 
        FILTER ( 'Data', 'Data'[TransactionDate] = MaxDate ),
        Data[Amount]
    )

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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