Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dax function is difficult

Hello, I'm a beginner at Power B.I

There are seven classrooms and there should be seven people per classroom.
Then, you can receive a total of 49 people with a total of 7*7=49, and now 23 people have entered the school, so you have to fill 26 more people.

As you can see in the image, a total of 26 numbers are shown, but if you click each class, the numbers are not correct.


I want to get a number normally.

I need your help
Thank you.

  • PC2790's avatar
    PC2790
    4 years ago

    Glad to help ğŸ™‚

    If your issue is resolved, please mark the answer as solution for others to benefit from it.

    Thanks

8 Replies

  • PC2790's avatar
    PC2790
    Community Champion

    Try:

     

    Measure =
    var studentsperclass = 7 

    return

    Calculate('Class',Class[Class] * studentsperclass - freshman[entrance into a school])

     

    Make sur eyou ahve relationship between Class and freshman table

  • Anonymous's avatar
    Anonymous
    Not applicable

    PC2790 

     

    thx.

     

    Should I do it like the image I posted?
    It's not working....

     

    • PC2790's avatar
      PC2790
      Community Champion

      Can you provide your data model and sample data?

      What data type is you class column?

      If each class has 7 students and it is fixed then there is no need to multiply it explicitly with 7.

      If your Class table contains the number of students, you can get the 7 number from there using:

       

      Measure =
      var selectedclass = Allselected(Class[Class]) 

      var Noofstudentsinclass = Count(Filter('Class', Class[Class] = selectedclass))

      return

      Noofstudentsinclass - freshman[entrance into a school]

       

      If single class has 7 students, then Noofstudentsinclass would always return 7 if one class is selected?Isn't it?

      And are you sure you want to subtract freshman[entrance into a school]?

      It will be easier to advice further if you can provide some sample data and your expected output.

  • Anonymous's avatar
    Anonymous
    Not applicable

    You can go to the url address and download the file.
    PC2790 

    https://drive.google.com/drive/folders/1DIDO3Wuw3jj0I9A03eszMfRkk5bQ31RV?usp=sharing

    You can go to the url address and download the file.

    The powerbi should have a value in the 'card' part.

    -> need to STU = (each class * 7) - Total number of students enrolled

    And if you press each classroom, you can see the number of students that you need

    For example, if you press A, the number "card" should be 5 people
    It's because two people are currently in class A.

  • Anonymous's avatar
    Anonymous
    Not applicable

    PC2790 

     

    You can go to the url address and download the file.

    The powerbi should have a value in the 'card' part.

    -> need to STU = (each class * 7) - Total number of students enrolled

     

    And if you press each classroom, you can see the number of students that you need

    For example, if you press A, the number "card" should be 5 people
    It's because two people are currently in class A.

     

    URL : https://drive.google.com/drive/folders/1DIDO3Wuw3jj0I9A03eszMfRkk5bQ31RV?usp=sharing

      • Anonymous's avatar
        Anonymous
        Not applicable

        PC2790 

         

        Ohhhhhhh! 

        Thanks a lot!
        It's amazing!!

        😀