Forum Discussion

bourne2000's avatar
bourne2000
Helper V
5 years ago
Solved

How to divide between two tables?

Hi

 

I am having below three tables,

 

 Main table 
   
School NameNumber of StudentsID NO
School 11001
School 22002
School 3503
School 41024
School 51805
School 69006
School 7507
School 81028
School 91809

 

 School 2 - Table 
   
School NameName of studentID NO
School 2Student 12
School 2Student 22
School 2Student 32
School 2Student 42
School 2Student 52
School 2Student 62

 

 

 School  9 - Table 
   
School NameName of studentID NO
School 9Student 19
School 9Student 29
School 9Student 39
School 9Student 49
School 9Student 59
School 9Student 69

 

I have connected School 2 and School 9 table with the main table through ID NO. It's many to one relationship

 

I want to count the number of records in School 2 and School 9 and divide the same with the number of students in the main table. For example, School 2 has 6 records and it has 200 students in the main table. I want to calculate the percentage, so 6/200 * 100 

 

I want the table as below

 

School NameNumber of StudentsTotal School 2 records% of students
School 220063%
School 918063%

 

Can you please advise how to do it? Do we need to write only Dax measures? or we can find the percentage without dax measures

  • Anonymous's avatar
    Anonymous
    5 years ago

    bourne2000 

    Try the following 2 measures, might give you some insights:

     

    School 2 =  COUNTROWS('School 2')/CALCULATE(SUM('Main Table'[Number of Students]),FILTER('School 2',[ID NO] in VALUES('Main Table'[ID NO])))

    School 9 = COUNTROWS('School 9')/CALCULATE(SUM('Main Table'[Number of Students]),FILTER('School 9',[ID NO] in VALUES('Main Table'[ID NO])))

     

     

     

    Paul Zheng _ Community Support Team
    If this post helps, please Accept it as the solution to help the other members find it more quickly.

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    bourne2000 

    Try the following 2 measures, might give you some insights:

     

    School 2 =  COUNTROWS('School 2')/CALCULATE(SUM('Main Table'[Number of Students]),FILTER('School 2',[ID NO] in VALUES('Main Table'[ID NO])))

    School 9 = COUNTROWS('School 9')/CALCULATE(SUM('Main Table'[Number of Students]),FILTER('School 9',[ID NO] in VALUES('Main Table'[ID NO])))

     

     

     

    Paul Zheng _ Community Support Team
    If this post helps, please Accept it as the solution to help the other members find it more quickly.