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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
jsdgooch
New Member

Calculate Sum of Points based on 2 Date Columns

Hi there!

 

Need help on calculating the Points of each member based on their Aniversary Date.  I am trying to figure out but I don't have advance knowledge in DAX.  I have created a calculated fields "From" and "To" based on the "Anniversary Date" and I wanted to use those to query the total points.

 

I have two tables, Members & Transactions and is linked via Member ID.


Members:

Member ID, Anniversary, From, To

1234, 8/20/2024, 8/20/2024, 3/31/2025

4567, 7/24/2023, 7/24/2024, 3/31/2025

 

Transactions:

Member ID, Date, Points

1234, 8/30/2024, 100

1234, 12/31/2024, 100

1234, 3/1/2025, 100

5678, 6/31/2024, 100

5678, 9/30/2024, 100

5678, 10/31/2024, 100

5678, 2/28/2025, 100

 

My desired result would be:

Members:

Member ID, Anniversary, From, To, Points

1234, 8/20/2024, 8/20/2024, 3/31/2025, 300

4567, 7/24/2023, 7/24/2024, 3/31/2025, 300

 

How can I achieve this?


Many thanks!

 

Regards,

Jorrel D.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@jsdgooch 

Points Measure = 
  VAR __From = MAX( 'Members'[From] )
  VAR __To = MAX( 'Members'[To] )
  VAR __Table = FILTER( 'Transactions', [Date] <= __To && [Date] >= __From )
  VAR __Result = SUMX( __Table, [Points] )
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...

View solution in original post

3 REPLIES 3
jsdgooch
New Member

OMG!

 

That does it!  The query is rather simple... am trying to use DATESBETWEEN but to no avail.

 

Many thanks for this!

 

Kudos!


Regards,

Jorrel D.

@jsdgooch Just say no to DAX time "intelligence" functions. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



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...
Greg_Deckler
Super User
Super User

@jsdgooch 

Points Measure = 
  VAR __From = MAX( 'Members'[From] )
  VAR __To = MAX( 'Members'[To] )
  VAR __Table = FILTER( 'Transactions', [Date] <= __To && [Date] >= __From )
  VAR __Result = SUMX( __Table, [Points] )
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...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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