Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Count all records from another table

Hi All, 

 

I have not found a way to do this at all yet, help would be appreciated. It should be relatively straightforward. I have a primary table of submitted records and a larger table with all non-submitted and submitted records. I need to be able to calculate headcount as a count of all non-submitted and submitted records. 

 

I have two tables:

 

Table 1 is the primary table and all statistics on submitted records are calculated. This table is only submitted records so as to maximise performance of the report and graphs. Most pages in the report uses Table 1 only.

TimeFrameCodeSlicerIDUserStatus
1 2020Course13ID2User 2Submitted
1 2020Course14ID3User 3Submitted
3 2019Course24ID4User 4Submitted

 

Table 2 has all records, both submitted and not submitted. 

TimeFrameCodeSlicer IDUserStatus
1 2020Course13ID1User 1DNR
1 2020Course13ID2User 2Submitted
1 2020Course14ID3User 3Submitted
3 2019Course24ID4User 4Submitted
4 2019Course25ID5User 5DNR
5 2019Course25ID6User 6DNR

 

Expected result:

For all courses in Table 1 I would like to be able to calculate the total number of distinct users in table 2. 

 

The headcount I would expect for Course 1 is 3.

 

I would like a dynamic measure so I can aggregate above the course level. This is why I have not used Summarized tables or calculated columns if I can avoid them. 

 

I have spent a few hours on this and while I can calculate it from Table 2 easily, it breaks when I try to use it with relationships. 

 

Help would be greatly appreciated. 

 

7 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous  - First, you mention Course 1 but I do not see a course 1 in your data. Where you referring to Course 13 and there should be 2 users, one that registered and one that did not?

     

    How are the tables related to one another? Or how are you attempting to relate the tables to one another?

     

    You could just leave them unrelated to one another and do something like:

     

    Measure = 

      COUNTROWS(

        FILTER('Table2', 'Table2'[Course] = MAX('Table1'[Course]) && 'Table2'[TimeFrameCode] = MAX('Table1'[TimeFrameCode]))

      )

     

    Something along those lines for example. 

  • Good morning, I have a table that has the detail of all the invoices of all the suppliers (Table invoices) and another that has the detail some of the proeveedores, I would like to know how I do to count the invoices, but only of the suppliers that coincide with those of the table of selected suppliers.

    Agrdezco of antemmano the help.