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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
davidap
Advocate I
Advocate I

DAX Retrieve value from another row and column within table based on matching criteria

Problem
New Column Aggregate ID should return the Index ID where the User matches and Paid Date is between the First and Last Service dates of an Index ID. The Index ID marks a major event with Aggregate ID marking other services.

 

Solution I created in the End

1) Create a table with deduplicate Index ID and Paid amounts, add a column flagging the highest paid

2) Query against it

 

Aggregate ID = maxx (filter(aggregateIdTable, transactionTable[User] = aggregateIdTable[User] && transactionTable[Paid Date] >= aggregateIdTable[First Service] && transactionTable[Paid Date] <= aggregateIdTable[Last Service] && aggregateIdTable[Is Paid Amount Max?] = "Yes"), aggregateIdTable[Index Id])

 

 

Data

UserStoreFirst Service  Last Service  Paid Date  PaidIndex IDAggregate ID
A67801B9/1/20239/1/20239/1/2023118.0  
A67801C9/2/20239/2/20239/2/2023177.0  
A67801A9/1/20239/2/20239/2/2023153.0A67801-A-9/1/2023-9/2/2023 
C94823A9/4/20239/4/20239/4/2023189.0A67801-A-9/4/2023-9/4/2023 
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @davidap 

 

You can try the following methods.

Aggregate ID = 
CALCULATE ( MAX ( 'Table'[Index ID] ),
    FILTER (ALLEXCEPT( 'Table','Table'[User]),
        [Paid Date] >= 'Table'[First Service] 
            && [Paid Date] <= 'Table'[Last Service] 
    )
)

vzhangti_0-1703038533081.png

Is this the result you expect? Please see the attached document.

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
davidap
Advocate I
Advocate I

Thanks all. I built a solution last night that put a deduplicated list User, First/Last Service Dates, and the Index IDs (minus blanks) into another table then did CALCULATE+FILTER to pull in the value in the User and Paid dates were within spans. I also assigned Index IDs to those with the highest $ on those dates, in case multiple indices were found.

Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

Column = CALCULATE(MAX(Data[Index ID]),FILTER(Data,Data[User]=EARLIER(Data[User])&&Data[First Service  ]<=EARLIER(Data[Paid Date  ])&&Data[Last Service  ]>=EARLIER(Data[Paid Date  ])))

Hope this helps.

Ashish_Mathur_0-1703042571941.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-zhangti
Community Support
Community Support

Hi, @davidap 

 

You can try the following methods.

Aggregate ID = 
CALCULATE ( MAX ( 'Table'[Index ID] ),
    FILTER (ALLEXCEPT( 'Table','Table'[User]),
        [Paid Date] >= 'Table'[First Service] 
            && [Paid Date] <= 'Table'[Last Service] 
    )
)

vzhangti_0-1703038533081.png

Is this the result you expect? Please see the attached document.

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This was closest to what I used in the end. I added a column determine whether the Index had the max $ amount to break ties.

ryan_mayu
Super User
Super User

@davidap 

what's the expected output based on the sample data?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.