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

Count of rows not in related table

Hi,

I have two tables with ID column common in both tables, i want to calculate count of ID's in current month from table1 based on createddate column which are not present in Table2

Table1                         Table2 

ID   CreateDate           ID

1     1/8/19                  1

2      2/8/19   

3      3/8/19       

 

Output should be = 2

Thanks,

Pankaj

 

 

1 ACCEPTED SOLUTION

Hi Pankaj,

 

If I understood correct, you are trying to find the count of Id's associated with current month in table1 and those Id's should not be present in Table2. 

Check if the below solution works for you.

Create column in Table1 which is true if values in present in table2 and false if value is not present in table2.

Use the above column to create a measure for the Id's created this month in table1 and have calculated column set to false.

 

Column = VAR _v1 = RELATED('Table (3)'[Id])
RETURN IF('Table (2)'[ID] = _v1, TRUE(),FALSE())
 
Measure = VAR _v1 = FORMAT(TODAY(),"MMYYYY")
VAR _v2 = CALCULATE(COUNT('Table (2)'[ID]),
FILTER('Table (2)', FORMAT('Table (2)'[CreatedDate], "MMYYYY") = _v1 && 'Table (2)'[Column] = FALSE()))
RETURN _v2
 
Data:
sample data.PNG
 
Result:
result.PNG
 
Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.
 
Regards,
Ananth

View solution in original post

3 REPLIES 3
v-anabat
Microsoft Employee
Microsoft Employee

Hi @Anonymous ,

can you please provide few more examples for the dataset, also the expected result for it.

 

Regards,

Ananth


 

Anonymous
Not applicable

Here is the example and expected output :

Table A                                  Table B

ID   CreatedDate                    ID 

1     1/8/2019                         14

2      12/8/2019                           

3      14/8/2019

4      1/7/2019

 

Wants to find out count of ID from table A which are not avialble in Table B for current month, assuming current month is august

Output should be : 2

 

Thanks,

Pankaj


@v-anabat wrote:
Hi @Anonymous ,

can you please provide few more examples for the dataset, also the expected result for it.

 

Regards,

Ananth


 


 

 

 

Hi Pankaj,

 

If I understood correct, you are trying to find the count of Id's associated with current month in table1 and those Id's should not be present in Table2. 

Check if the below solution works for you.

Create column in Table1 which is true if values in present in table2 and false if value is not present in table2.

Use the above column to create a measure for the Id's created this month in table1 and have calculated column set to false.

 

Column = VAR _v1 = RELATED('Table (3)'[Id])
RETURN IF('Table (2)'[ID] = _v1, TRUE(),FALSE())
 
Measure = VAR _v1 = FORMAT(TODAY(),"MMYYYY")
VAR _v2 = CALCULATE(COUNT('Table (2)'[ID]),
FILTER('Table (2)', FORMAT('Table (2)'[CreatedDate], "MMYYYY") = _v1 && 'Table (2)'[Column] = FALSE()))
RETURN _v2
 
Data:
sample data.PNG
 
Result:
result.PNG
 
Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.
 
Regards,
Ananth

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.

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.