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
Patto
Helper II
Helper II

Help with DAX Calculation

Hi all, if someone could help with the below DAX calc that would be awesome...

 

Ok...

I have a list of study courses and via relationship I can determine the number of students in a course - easy.

But now I want a DAX calc to count the number of courses where the number of students in those courses is less than say 10.

This will enble me to show a visual with the number of courses with less than 10 students as a percentage of total courses

 

Hope this makes sense?

 

Cheers

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Try

formula 1
Count of student = SUM('Table'[student])

formula 2
count of courses = 
calculate(countx(
    VALUES(course[ID])  // Avg till this level
    , course[ID]
),[Count of student] >10)

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

Try

formula 1
Count of student = SUM('Table'[student])

formula 2
count of courses = 
calculate(countx(
    VALUES(course[ID])  // Avg till this level
    , course[ID]
),[Count of student] >10)

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Thank you for your help, unfortunately I get an error "CALCULATE has been used in a True/False expression that is used as a table filter expression".

 

I think I need to make myself clearer as well...

Ok I have 4 tables:

Table 1 - a dimension that contains all courses (eg degree of computer science)

Table 2 - a dimension that contains all topics that can be taken in that course (eg data modeling in power BI)

Table 3 - a dimension of student information

Table 4 - the fact table that joins it all together (eg, student 1 has enrolled in the power BI topic that is attached to the computer science course)

 

Now what I am wanting to do is show a visual that tells the user the following:

Axis = course name (eg degree of computer science)

Value1 = total number of topics in a course (eg 10 topics in that course)

value2 = total number of those topics that have less than 1 student enrolment. (eg 1 topic of the 10 has only 1 enrolment)

 

I hope that helps - Thoughts?

 

So I have already completed:

- a distinct count of students - tick

- a distinct count of topics - tick

- And I can plot this in a visual against the course.

 

I am missing, 

- the number of topics where the student enrolment = 1

 

Cheers

dax
Community Support
Community Support

Hi Patto,

I am not clear about your requirement, if possible could you please inform me more detailed information(such as your expected output and your sample data)? Then I will help you more correctly.

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

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.