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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Anonymous
Not applicable

Count based on multiple columns from different tables

Hi PBI Community,

 

I am working on an interesting problem. I have two tables A and B. 

Table A: Contains a list of transactions with a transaction number, item, date and status.

Table B: Contains the list of items that is unique.

Table B has a 1 to many relationship with table A.

 

Objective: Count the number of elements in Table A based on values in other columns within and display as a calculated column in table B.

 

Criteria: 

For the highest Transaction number for each item in table A:

If the due date is after 5 January AND if status is A or B

Count +1 for corresponding item in table B.

 

Data and expected result:

TABLE A
Transaction NumberItemDue DateStatus
1Item123-JanA
2Item125-FebB
3Item110-JanC
1Item211-JanA
1Item311-JanA
2Item311-JanC
4Item313-JanB
4Item302-JanA
1Item401-JanC
1Item115-JanA
1Item416-JanB
1Item517-JanB
1Item517-JanA

 

TABLE B
ItemResult
Item10
Item21
Item31
Item41
Item52

 

Eg1. Item 1 has 4 transactions, the highest Transaction number is 3 with a due date of 10 Jan and Status C, so result is 0 in Table B.

Eg2. Item 2 has 1 transaction, with a due date of 11 January with a status A so result in Table B is 1.

Eg3. Item 5 has 2 transactions of the same number with the same due date but different statuses A and B so result in table B is 2.

 

Where I've gotten to: I've managed to flag the max transaction number for each item in table A.

 

Max Transaction = CALCULATE(MAX(Table A[Transaction Number]),ALLEXCEPT(Table A,Table A[Item]))

 

Any one have any ideas on how to obtain the column Result in table B based on these criteria? 

 

Thanks,

Dilip

 

1 REPLY 1
Anonymous
Not applicable

Why not do it in Power Query?

Best
D

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.