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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
lgzurich2024
New Member

DAX Measure for YTD Calculation with Condition

Hi All,

 

I have not been able to find a solution to my below problem.

 

I have the following table which includes the payment to date information for 4 x claims

 

Date Claim_IDPayment to Date
01/01/2024 4981791000
01/02/2024 4981792000
01/01/2024 706401235
01/02/2024 706401250
01/01/2024 719069900
01/01/2024 860121300
01/02/2024 8601211800

 

I would like to build a DAX measure to calculate the YTD SUM of Payments with certain conditions:
1. 2024 Jan should equal the sum of all of the January Payments (2435)

2. 2024 Feb should equal (4950) the sum of all of the updated Payments per ID, plus the January ID - 719069, as it did not have an updated payment. The February total should not sum the previous payment values in the total with exception of 719069 as it did not have an updated payment record in Feb 24'.

 

The resulting measure should show the below totals when pulled into a matrix, and would be dynamic, to deal with expanded data and the inclusion of Mar', Apr' data etc in the future.

YearMonthPayment YTD
2024Jan2435
2024Feb4950
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@lgzurich2024 Try:

 

Measure 2 = 
    VAR __Sum = SUM( 'Table'[Payment to Date] )
    VAR __Month = MONTH( MAX( 'Table'[Date] ) )
    VAR __CurrentClaims = DISTINCT( 'Table'[Claim_ID] )
    VAR __LastMonthClaims = DISTINCT( SELECTCOLUMNS( FILTER( ALL( 'Table' ), MONTH( [Date] ) = __Month - 1 ), "__ClaimID", [Claim_ID] ) )
    VAR __Except = EXCEPT( __LastMonthClaims, __CurrentClaims )
    VAR __Result = __Sum + SUMX( FILTER( ALL( 'Table' ), [Claim_ID] IN __Except ), [Payment to Date] )
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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@lgzurich2024 Try:

 

Measure 2 = 
    VAR __Sum = SUM( 'Table'[Payment to Date] )
    VAR __Month = MONTH( MAX( 'Table'[Date] ) )
    VAR __CurrentClaims = DISTINCT( 'Table'[Claim_ID] )
    VAR __LastMonthClaims = DISTINCT( SELECTCOLUMNS( FILTER( ALL( 'Table' ), MONTH( [Date] ) = __Month - 1 ), "__ClaimID", [Claim_ID] ) )
    VAR __Except = EXCEPT( __LastMonthClaims, __CurrentClaims )
    VAR __Result = __Sum + SUMX( FILTER( ALL( 'Table' ), [Claim_ID] IN __Except ), [Payment to Date] )
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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you kindly.

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.