Forum Discussion

markovuc's avatar
markovuc
Regular Visitor
2 years ago
Solved

What this code actailly do?

I dont understand what do code Grand Total= Calculate([Total obtained marks], ALL (Marks[Subject])) ? Please check screen shot. Calculate removes filters in visual and I dont understand what ALL do. It removes the same filter as calculate subjects???

  • Fowmy's avatar
    Fowmy
    2 years ago

    markovuc 

    Imagine you have a formula to calculate the total marks obtained, and it takes into account different subjects. Now, if you use the CALCULATE function with ALL(Marks[Subject]) as an argument, it's like telling the formula to ignore the influence of the subject filter. So, on each row, you get the total marks without being influenced by the specific subject, giving you a broader picture across all subjects.


    Hope that clarifies it! If you have any specific questions or need more examples, feel free to ask.

4 Replies

  • tackytechtom's avatar
    tackytechtom
    Most Valuable Professional

    Hi markovuc ,

     

    The formular calculates the Grand Total by using the [Total obtained marks] measure and removing the applied filter to Marks[Subject] (due to "ALL()" )

     

    That is why your visual shows the same number for all subjects in the Grand total column. PBI applies a filter to each row of your table, namely where Marks[Subject] = "Bio" for row 1, Marks[Subject] = "Computer" for row 2 etc. Now the ALL() function makes your Grand Total measure disregard that exact filter and therefore it shows 355 for all rows whereas the filter for the other measure [Total obtained marks] is still being applied.

     

    hope this helps 🙂

     

    /Tom
    https://www.tackytech.blog/
    https://www.instagram.com/tackytechtom/

  • markovuc 

    In your formula, Caculate is used to modify how your measure [Total obtained marks] is evaluated. By applying ALL (Marks[Subject]) as an argument to the Calculate functon, it removes the filter coming from Subject column, that is the reason on each row, you see the total amount where [Total obtained marks] is not affected by subject.

    • markovuc's avatar
      markovuc
      Regular Visitor

      Hi guys, many thanks for your replies. Happy 2024.! I dont understand following sentence "In your formula, Caculate is used to modify how your measure [Total obtained marks] is evaluated."How the measure is evaluated with calculate and without ? 

      I still dont understand what Calculate do? How Calculate operate. 

      • Fowmy's avatar
        Fowmy
        Super User

        markovuc 

        Imagine you have a formula to calculate the total marks obtained, and it takes into account different subjects. Now, if you use the CALCULATE function with ALL(Marks[Subject]) as an argument, it's like telling the formula to ignore the influence of the subject filter. So, on each row, you get the total marks without being influenced by the specific subject, giving you a broader picture across all subjects.


        Hope that clarifies it! If you have any specific questions or need more examples, feel free to ask.