Forum Discussion

sarath5140's avatar
sarath5140
Helper I
7 years ago
Solved

Count Rows from another table based on date filter and group by column

Hi,

 

Can anyone help me in solving my below problem.

 

I have two tables TableA and TableB

 

TableA

 

CategoryIDDate
FactoryA12347/12/2018 0:00
FactoryA12457/13/2018 0:00
FactoryA121657/17/2018 0:00
FactoryB126787/24/2018 0:00
FactoryB126798/15/2018 0:00
FactoryB126808/21/2018 0:00
FactoryB126812/19/2019 0:00
FactoryC126828/6/2018 0:00
FactoryC126838/7/2018 0:00
FactoryC126849/13/2018 0:00
FactoryC1268510/30/2018 0:00
FactoryD126867/6/2018 0:00
FactoryD126877/19/2018 0:00
FactoryD126887/21/2018 0:00
FactoryD126898/3/2018 0:00
FactoryE126907/31/2018 0:00
FactoryE126918/3/2018 0:00
FactoryE126928/15/2018 0:00
FactoryE126938/18/2018 0:00
FactoryF126948/30/2018 0:00
FactoryF126959/18/2018 0:00
FactoryF1269611/1/2018 0:00
FactoryF1269711/22/2018 0:00

 

Table B

 

CategoryIdDate
FactroyA19397/13/2018 0:00
FactroyA19407/17/2018 0:00
FactroyA19417/28/2018 0:00
FactoryB19429/17/2018 0:00
FactoryB19439/21/2018 0:00
FactoryB194410/8/2018 0:00
FactoryB194510/16/2018 0:00
FactoryC19468/6/2018 0:00
FactoryC19478/7/2018 0:00
FactoryC19489/13/2018 0:00
FactoryC194910/30/2018 0:00
FactoryD19507/19/2018 0:00
FactoryD19517/21/2018 0:00
FactoryD19529/29/2018 0:00
FactoryD195310/11/2018 0:00
FactoryD195410/19/2018 0:00
FactoryE19557/31/2018 0:00
FactoryE19568/15/2018 0:00
FactoryE19578/18/2018 0:00
FactoryF19588/30/2018 0:00
FactoryF195911/1/2018 0:00
FactoryF196011/22/2018 0:00

 

Now, i would like to calculate the count of rows in tableB when Table A Category column matches with TableB Category column. So, my output should apppear like this

 

Output :-

 

CategoryTableACountTableBCount
FactoryA33
FactoryB44
FactoryC44
FactoryD45
FactoryE43
FactoryF43

 

I am able to acheive the TableB count by using the below dax

Output = calculate(countrows(tableB), Filter(TableB, TableB[Category] = TableA[Category])), but my output should change when I apply the date filter on TableA, my tableB count should also change based on the date slicer applied on TableA filter.

 

Note :- Both of my tables are not related to each other 

 

Appreciate your help!

 

Thanks