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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors